I am trying to log in to my gmail account via Selenium on Python and the problem is: I can enter the username correctly, but nothing is entered into the password section
To put in context, for Gmail, you have to put your username in, then move on to the password section after. I have attempted to do the following solutions: - refreshing the page in between entering username and pword (this causes you to go to some other screen) - waiting for the password box to appear (didn't make any change) - trying to access the box by id instead of xpath (didn't work)
Here is my code below:
from selenium import webdriver
#from selenium.webdriver.support.ui import WebDriverWait
#from selenium.webdriver.support import expected_conditions as EC
keys = {
'url':'http://www.gmail.com',
'username':'xxxxxxxxxxxx',
'pword':'xxxxxxxxxxxx',
'email':'xxxxxxxxxxxx',
'title':'xxxxxxxxxxxx',
'text':'xxxxxxxxxxxxxx'
}
driver = webdriver.Safari()
driver.get(keys['url'])
driver.find_element_by_xpath('//*[@id="identifierId"]').click()
driver.find_element_by_xpath('//*[@id="identifierId"]').send_keys(keys['username'])
driver.find_element_by_xpath('//*[@id="identifierNext"]/content/span').click()
# wait for the password field to be visible
#wait = WebDriverWait(browser, 10)
#passwordElem = wait.until(EC.visibility_of_element_located((By.ID, "Passwd")))
#passwordElem.clear()
driver.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys(keys['pword'])
driver.find_element_by_xpath('//*[@id="passwordNext"]/content').click()
The commented sections are the edits I attempted to make.
Any help would be greatly appreciated. Thanks in advance.