9

Trying to input username during login using send_keys() method. I guess it's able to locate the input element, as when I run until before send_keys it works. With sending a string value in send_keys, it's throwing an error.

selenium.common.exceptions.WebDriverException: Message: Expected [object Undefined] undefined to be a string

What am I missing?

Python : 3.5
Selenium 3.3.1
Firefox Developer Edition or Nightly (currently version > 52)
My code snippet:

login_url = "https://korunet.co.nz/"
driver = webdriver.Firefox()
driver.get(login_url)
WebDriverWait(driver, 30).until(ec.visibility_of_element_located((By.CSS_SELECTOR, '#IDToken1')))

elem = driver.find_element_by_css_selector('#IDToken1')
elem.click()
elem.clear()
elem.send_keys("10101")

Traceback (most recent call last):

File "D:/PycharmProjects/JCBbidEntry/tests/loop2.py", line 29, in elem.send_keys("10101")
File "C:\Users\BaruaR\AppData\Roaming\Python\Python35\site-packages\selenium\webdriver\remote\webelement.py", line 347, in send_keys self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
File "C:\Users\BaruaR\AppData\Roaming\Python\Python35\site-packages\selenium\webdriver\remote\webelement.py", line 491, in _execute return self._parent.execute(command, params)
File "C:\Users\BaruaR\AppData\Roaming\Python\Python35\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute self.error_handler.check_response(response)
File "C:\Users\BaruaR\AppData\Roaming\Python\Python35\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)

philipvr
  • 5,738
  • 4
  • 32
  • 44
user1751844
  • 101
  • 1
  • 2

6 Answers6

4

Appears to be resolved, at least for me with the latest version of geckodriver 0.16: https://github.com/mozilla/geckodriver/releases/tag/v0.16.0

Note that version 0.16 requires selenium 3.4.

-Erinn

3

Same here ... Seems to be a problem with FIREFOX ... it works as expected with CHROME ;-(

manatlan
  • 1,091
  • 1
  • 9
  • 18
  • 1
    It's in the unstable versions of firefox only, the release version and the older versions work fine. I donno where to file this bug though. – Ammar Apr 07 '17 at 15:56
  • thanks @najjarammar - after using regular firefox everything worked out fine – wasabigeek Apr 19 '17 at 10:33
2

i have also same problem in my case my geckodriver is 64bit but firefox is 32 bit it throws an error

0

Had a Firefox update and the same happened to me. Re-installed Geckodriver 64-bit (https://github.com/mozilla/geckodriver/releases) and it worked for me.

0

Updating to geckodriver 0.17.0 fixed the issue for me
Firefox 53.0.3
Selenium 3.4.3
Python 3.6

binary = FirefoxBinary('C:\\Program Files (x86)\\Mozilla Firefox\\Firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary) 
driver.get(url)

emailInput = driver.find_element_by_id("login-username")
emailInput.send_keys("username")
Viragos
  • 561
  • 6
  • 15
0

A solution that worked for me is to set value attribute, instead of using send_keys.

driver.execute_script("document.getElementById('login-username').setAttribute('value', 'username')")
alexxei
  • 40
  • 6