0
votes
option = ChromeOptions()
chrome_prefs = {}
driver = Chrome(chrome_options=option) #getting the web driver object
try:
    url="https://www.groupon.fr/merchant/center/"
    driver.get(url)
    driver.maximize_window()
    email="xyz"
    password="abc"
    email_box=WebDriverWait(driver,10).until(lambda x: x.find_element_by_id("emailInput"))
    email_box.send_keys(email)
    password_box=WebDriverWait(driver,10).until(lambda x: x.find_element_by_id("passwordInput"))
    password_box.send_keys(password)
    attempts=0
    while True:
        try:
            submit = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CLASS_NAME,"submitButton button-primary button-cta")))
            driver.execute_script("arguments[0].click();", submit)
            break
        except:
            traceback.print_exc(file=sys.stdout)
            attempts+=1
            if (attempts>3):
                raise Exception("Error")
            continue
finally:
    driver.quit()

Output

Traceback (most recent call last): File "", line 22, in submit = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CLASS_NAME,"submitButton button-primary button-cta"))) File "C:\Users\sheik\Anaconda2\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) TimeoutException: Message:

I am actually trying to login on this page and after filling the email and password, I am unable to find the submit button although I am using the correct class name of the button. I have tried it from xpath too but no success.

What is the issue in my code?The html of the page

1
What is it supposed to do? You have provided next to no information. Everyone has better things to do than try to figure out what your code is supposed to do. Please edit your question to provide background and context.Charlie Crown
It would be good if you share the html code of the part as well.Sandeep
I have updated the query. The html image of the page is attached. Kindly bear with me since its my first post here and I am struggling with it.Sheraz Sharif
The problem is that you are using By.CLASS_NAME but sending it 3 class names, "submitButton button-primary button-cta". Either choose one of the three or turn it into a CSS selector and use all three, e.g. Justin's answer.JeffC

1 Answers

1
votes

I do not have selenium installed yet on my new machine but you can search using CSS selectors. I know the example code is not python but you should be able to figure out the corresponding python code.

Edit. Try the following:

submit = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,".submitButton.button-primary.button-cta")))