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
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