-1

I'm trying to automatically log into Gmail via a Python script. I'm using the selenium webdriver. I've managed to get my email entered but I don't know how to get my password entered as well. I've already checked past questions on here but the selectors mentioned in the answers don't seem to work. I keep getting an "Unable to locate element" error.

The code I tried:

driver.find_element_by_name("password").send_keys(pw)
Serwj
  • 43
  • 1
  • 8

3 Answers3

0

This should be a comment but I don't have the 50 required rep. I would try the GMail Python API. It should be a lot easier:

https://developers.google.com/gmail/api/quickstart/python

Myles Hollowed
  • 546
  • 4
  • 16
0
  1. Make sure the element name is correct
  2. make sure the element is visible (not overlapped by another element. ex: by virtual keyboard (in mobile application) or by auto-complete box)
Steven
  • 45
  • 4
0

You can use wait before if wanted otherwise you can achieve this simlply by ID

Gpassword = driver.find_element_by_id("password")
Gpassword.send_keys("xxxxxxxx")
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
  • idk if this is what you meant but putting a sleep after the email input made it work, so thanks. is there any way to figure out if the website in the web driver has finished loading so I don't have to use sleep? – Serwj Nov 08 '17 at 10:10