google account login automation with selenium causes error [duplicate]

google account login automation with selenium causes error [duplicate]



This question already has an answer here:



I am trying to login to Google with selenium. The steps are simple, first you type email and hit next, then you type password and hit next. My code looks like this:


driver = webdriver.Firefox()
driver.get("https://accounts.google.com/signin")

driver.implicitly_wait(3)

driver.find_element_by_id("identifierId").send_keys("email")
driver.find_element_by_id("identifierNext").click()

password = driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[1]/div/form/content/section/div/content/div[1]/div/div[1]/div/div[1]/input")
password.send_keys("password")

element = driver.find_element_by_id('passwordNext')
driver.execute_script("arguments[0].click();", element)



The first part of code (email part) works perfectly. I also checked the last part (hitting next after the password is written) and it also works great. The only problem is with password. when I try to do password.send_keys("password") it causes the following error:


password.send_keys("password")


TypeError: object of type 'FirefoxWebElement' has no len()



Any suggestions on what to do?



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




1 Answer
1



The problem was, I just had to wait for passwords pressence and visibility to be loaded, like this:


driver = webdriver.Firefox()
driver.get("https://accounts.google.com/signin")

driver.implicitly_wait(3)

driver.find_element_by_id("identifierId").send_keys("email")
driver.find_element_by_id("identifierNext").click()

driver.implicitly_wait(8)
password = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@type='password']")))
password = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//input[@type='password']")))

password = driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[1]/div/form/content/section/div/content/div[1]/div/div[1]/div/div[1]/input")
password.send_keys("password")

element = driver.find_element_by_id('passwordNext')
driver.execute_script("arguments[0].click();", element)

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?