python selenium login error despite use of WebDriverWait
Try out this...
find_element_by_name is not able to find that element so you need to use xpath for it.
Loading selenium to handle java on leaderboard page
#
path_to_chromedriver = 'C:/python351/chromedriver/chromedriver.exe'browser2 = webdriver.Chrome(executable_path = path_to_chromedriver)
Login with selenium
#
login_url = 'https://www.fitbit.com/login'
browser2.get(login_url)
browser2.implicitly_wait(5)
email1 = browser2.find_element_by_xpath(".//*[@id='loginForm']/fieldset/dl/dd[1]/input")
email1.send_keys('notrealemail@mail.com')
password1 = browser2.find_element_by_xpath(".//*[@id='loginForm']/fieldset/dl/dd[2]/input")
password1.send_keys('madeuppass')
form1 = browser2.find_element_by_class('common-btn common-btn-submit track-Auth-Login-ClickFitbit')
form1.click()
#Do reply if you need more help. I ran this code in Eclipse with java syntax it is working fine..Happy Learning.. Enjoy :-)
You use WebDriverWait
in a wrong way. Please refer to following line:
email = WebDriverWait(browser2, 10).until(EC.presence_of_element_located((By.ID,'email')))
This should allow to wait 10 seconds for required element before throwing an exception
You can also use try/except
to catch TimeOut
exception:
from selenium.common.exceptions import TimeoutExceptiontry: email = WebDriverWait(browser2, 10).until(EC.presence_of_element_located((By.ID,'email')))except TimeoutException: print('No Email input field found')