I am trying to log into a website with Selenium in Python. My code is below. I am able to sucessfully find (by_xpath) the username field and print its attributes. However, I am unable to send_keys to it or interact with it in any way. Further, I am unable to even select the password field, even though various xpath utilities tell me I am using the right address for the field.
I would like to input my username, password and click submit.
from selenium import webdriver
from selenium.webdriver.common import action_chains, keys
import time
driver = webdriver.Firefox()
driver.get("http://games.espn.go.com/ffl/signin?redir=http%3A%2F%2Fgames.espn.go.com%2Fffl%2Fleaguerosters%3FleagueId%3D1111554")
time.sleep(10)
driver.find_element_by_xpath("//input[@type='text']").send_keys("JimH")
driver.find_element_by_xpath("//input[@type='password']").clear()
driver.find_element_by_xpath("//input[@type='password']").send_keys("N0tMyR3@1P@55w0rd")
driver.find_element_by_xpath("//button[@type='submit']").click()
You can see in my code that the site that I am trying to access is this.
I have searched this forum extensively for a solution:
- This didn't help because I wasn't sure how to send keys, all this idd was click. Also it didn't provide descriptive error messages: Selenium Element not visible exception
- When I tried this one I got an exception that the box I was trying to select was outside the scroll window, which was not true: Unable to select radio button with selenium in Python
- Another post told me to select an frame which i was unable to do. (select_frame("disneyid-iframe") errored out on me)
The exception that I receive from my code above is pasted here:
/usr/bin/python2.7 /home/ff/PycharmProjects/Test/Test_action_chain.py
Traceback (most recent call last):
File "/home/ff/PycharmProjects/Test/Test_action_chain.py", line 8, in <module>
driver.find_element_by_xpath("//input[@type='text']").send_keys("JimH")
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 328, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing})
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 454, in _execute
return self._parent.execute(command, params)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 181, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
at fxdriver.preconditions.visible (file:///tmp/tmpOFHnLq/extensions/fxdriver@googlecode.com/components/command-processor.js:9981)
at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmpOFHnLq/extensions/fxdriver@googlecode.com/components/command-processor.js:12517)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpOFHnLq/extensions/fxdriver@googlecode.com/components/command-processor.js:12534)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpOFHnLq/extensions/fxdriver@googlecode.com/components/command-processor.js:12539)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpOFHnLq/extensions/fxdriver@googlecode.com/components/command-processor.js:12481)