0

I was trying to login to Gmail using selenium. I got the ID element, next button element but I am unable to attain password element.

This is the code snippet.

browser = webdriver.Firefox(executable_path = '/Users/ritikjangir/Downloads/geckodriver')
browser.get('http://gmail.com')

emailE = browser.find_element_by_id('identifierId')
emailE.send_keys(email)

nextE = browser.find_element_by_class_name('CwaK9')
nextE.click()

passE = browser.find_element_by_name('password')
passE.send_keys(password)

Email and password are variables that store my id and password as a string.

This gives the following error:

============ RESTART: /Users/ritikjangir/Documents/LineEmailer.py ============ Traceback (most recent call last): File "/Users/ritikjangir/Documents/LineEmailer.py", line 26, in passE.send_keys(password) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys 'value': keys_to_typing(value)}) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: Element is not reachable by keyboard

and the worst part is, it ran once.

Enter password element's attr. are:

input type="password" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="current-password" spellcheck="false" tabindex="0" aria-label="Enter your password" name="password" autocapitalize="off" autocorrect="off" dir="ltr" data-initial-dir="ltr" data-initial-value="">

Ritik Jangir
  • 87
  • 2
  • 11
  • Which line is the exception being thrown on? The error is that the element isn't reachable by keyboard which generally means that the element isn't one that can be typed into, e.g an INPUT field, etc. – JeffC Jan 14 '19 at 20:15
  • The password element. passE = browser..... snip ...... – Ritik Jangir Jan 15 '19 at 05:55

2 Answers2

0

Have you tried a :

nextE = browser.find_element_by_class_name('CwaK9') nextE.click()
time.sleep(2)
passE = browser.find_element_by_name('password') passE.send_keys(password)

Since it have worked once, it seems that between clicking and filling the data, we need some time to activate the snippet.

0

try using css selector for password element

passE = browser.find_element_by_css_selector('input[type=password]')
passE.send_keys(password)
Ankit Agrawal
  • 257
  • 1
  • 12