SendKeys not working in Firefox with Selenium 3.3.1 and GeckoDriver 0.15.0

9,086 views
Skip to first unread message

kfauto13

unread,
Mar 31, 2017, 12:18:11 AM3/31/17
to Selenium Users
Selenium Version: 3.3.1
Geckodriver version: 0.15.0
Firefox version: Nightly (55.0.a1)

I updated Selenium yesterday to 3.3.1 and took the latest GeckoDriver 0.15.0. As a preface, everything works fine in Chrome and I didn't have to change any existing code.

When I try to run a test using Firefox, it successfully launches the browser and is able to click elements (buttons, the field I'm trying to input text into, etc) and navigate through the program. But I cannot figure out a way to get text entered into the field. I have put breakpoints and checked that Selenium can get the element, it's displayed, it's enabled, and everything comes back fine. I have even put some text into the field and verified that Selenium sees that text and it does. I am able to run just fine using Selenium 2.53 and an older version of the browser but we need to get Selenium 3 implemented. I have spent a couple of days googling the problems I'm running into and I'm not getting anywhere with this.

The error I receive when trying to enter text is this:

WARNING: Exception thrown
org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'ADMINIB-8F07IP5', ip: '9.76.42.45', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\IBM_AD~1\AppData\Local\Temp\rust_mozprofile.oHMoJtANs1zD, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=55.0a1, platformVersion=6.1, moz:processID=12100, browserName=firefox, platformName=windows_nt}]
Session ID: 9b3f7bb1-48ae-4e36-afdd-12b1c4e7f7ef
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:99)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:43)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:495)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:332)
at com.sun.proxy.$Proxy15.sendKeys(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.sendKeys(EventFiringWebDriver.java:355)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:495)
at org.openqa.selenium.remote.server.KnownElements$1.invoke(KnownElements.java:64)
at com.sun.proxy.$Proxy16.sendKeys(Unknown Source)
at org.openqa.selenium.remote.server.handler.SendKeys.call(SendKeys.java:50)
at org.openqa.selenium.remote.server.handler.SendKeys.call(SendKeys.java:29)
at java.util.concurrent.FutureTask.run(FutureTask.java:277)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:785)

Has anyone had any experience with this? Unfortunately I'm unable to provide a link to test against as it's inside my company intranet.

Thanks!

Dollar Strike

unread,
Mar 31, 2017, 8:01:12 AM3/31/17
to Selenium Users
There're few issues in geckodriver. I have faced issue with Geckodriver while clicking an element. I can just give alternatives.
1. Did you try using System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"false"); or using Firefox options setting up the capabilities. 
2. Try using JavascriptExecutor to set value
3. Copy the string to the clipboard (java.awt) paste it in the Text box

Downgrade the version.

Let us know if you find any other solution which worked

Regards
Charan - Security Analyst | Test Automation Engineer | Blogger
https://seleniumbycharan.wordpress.com

Andreas Tolfsen

unread,
Mar 31, 2017, 9:16:16 AM3/31/17
to seleniu...@googlegroups.com
Also sprach 'kfauto13' via Selenium Users <selenium-
us...@googlegroups.com>:

> Selenium Version: 3.3.1
> Geckodriver version: 0.15.0
> Firefox version: Nightly (55.0.a1)
>
> I updated Selenium yesterday to 3.3.1 and took the latest
> GeckoDriver 0.15.0. As a preface, everything works fine in Chrome
> and I didn't have to change any existing code.
>
> When I try to run a test using Firefox, it successfully launches
> the browser and is able to click elements (buttons, the field I'm
> trying to input text into, etc) and navigate through the program.
> But I cannot figure out a way to get text entered into the field.

From your stacktrace it looks like Selenium is sending the wrong
JSON body to geckodriver. geckodriver expects

{text: "string"}

whereas RemoteWebElement.java in Selenium sends

{value: ["s", "t", "r", "i", "n", "g"]}

I would file a bug with Selenium.

kfauto13

unread,
Apr 3, 2017, 8:50:22 AM4/3/17
to Selenium Users
1. Yes, it didn't seem to make any difference what properties I changed or set.
2. I don't really want to do this. The same code is working for me on Chrome and IE, and it used to work just fine in Selenium 2 (2.53.1).
3. This could be an option, but I already know of places in our applications that this doesn't work correctly.

Thanks for the suggestions! It looks to me like there's a problem in the geckodriver or in selenium's handling of the geckodriver.

kfauto13

unread,
Apr 3, 2017, 8:52:42 AM4/3/17
to Selenium Users
I think you're right! I actually just looked at the commits since release to geckodriver and it looks like this problem may be fixed in the next release. I see this in there: 
marionette: make Send Keys and Send Alert Text accept a string
I'll keep my fingers crossed.

Thanks for your help, I appreciate it!

message...@gmail.com

unread,
Apr 3, 2017, 1:37:46 PM4/3/17
to Selenium Users
If send keys method is not working try using the following script 

    WebElement w1 = driver.findElement(By.xpath("//input[@id='lst-ib']"));
        
        myExecutor.executeScript("arguments[0].value='Steve';",w1);


Thanks 
Steve 

Anish Pillai

unread,
Apr 3, 2017, 9:36:31 PM4/3/17
to Selenium Users
Hi,

I have not tried Firefox Nightly (55.0.a1), but I have been using Selenium 3.3.1, GeckoDriver 0.15.0 and Firefox 52.0.1 and I'm not getting this issue with SendKeys.


Cheers,
Anish
AutomationTestingHub

kfauto13

unread,
Apr 4, 2017, 7:06:15 AM4/4/17
to Selenium Users
Really? I didn't change any code when updating from Selenium 2 to 3 and everything works fine in Chrome (I still need to try IE), but I can't get Firefox to work due to the sendKeys problem. I tried both Nightly and using Firefox 52 and the same problem occurred in both. 

Are there any settings (set system property, capability, firefoxOption, etc) that you're using with GeckoDriver? It seems that no matter what I set I run into the same problem.

Prakash F

unread,
Apr 5, 2017, 2:49:03 AM4/5/17
to Selenium Users



Is there any related changes in key events in recent Selnium 3.3.1 and GeckoDriver v0.15.0 ?

I use Actions & Key events for Keyboard shortcuts like undo/redo/delete

           actions.keyDown(command).sendKeys("z").keyUp(command).perform();



It works fine in Chrome but not in firefox.

Is there any workarounds or else should I wait for next update ?

Thanks.

Manzoor Ahmad

unread,
Apr 12, 2017, 8:51:15 AM4/12/17
to Selenium Users
its issue with the latest firefox53 versio. Try using firefox52, for me it works fine

Veith Zäch

unread,
Apr 13, 2017, 2:09:45 AM4/13/17
to Selenium Users
Same problem with firefox on a mac

if you POST on firefox

POST localhost:4444/wd/hub/session/ac9fde47-263f-4367-bbf0-b80a9bbbe741/keys
BODY {"value":["a"]}

you get 500 error with following Body:

{
  "state": "unknown command",
  "sessionId": "ac9fde47-263f-4367-bbf0-b80a9bbbe741",
  "hCode": 2103662491,
  "value": {
    "additionalInformation": "\nDriver info: driver.version: RemoteWebDriver",
    "localizedMessage": "sendKeysToActiveElement\nBuild info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'\nSystem info: host: 'z-industries.local', ip: '192.168.10.112', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_102'\nDriver info: driver.version: RemoteWebDriver",
    "systemInformation": "System info: host: 'z-industries.local', ip: '192.168.10.112', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_102'",
    "supportUrl": null,
    "cause": null,
    "stackTrace": [
      {
        "fileName": "AbstractHttpCommandCodec.java",
        "nativeMethod": false,
        "methodName": "encode",
        "className": "org.openqa.selenium.remote.http.AbstractHttpCommandCodec",
        "hCode": -1245155714,
        "lineNumber": 220,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "AbstractHttpCommandCodec.java",
        "nativeMethod": false,
        "methodName": "encode",
        "className": "org.openqa.selenium.remote.http.AbstractHttpCommandCodec",
        "hCode": -1245155816,
        "lineNumber": 118,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "HttpCommandExecutor.java",
        "nativeMethod": false,
        "methodName": "execute",
        "className": "org.openqa.selenium.remote.HttpCommandExecutor",
        "hCode": -1852790172,
        "lineNumber": 157,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "DriverCommandExecutor.java",
        "nativeMethod": false,
        "methodName": "execute",
        "className": "org.openqa.selenium.remote.service.DriverCommandExecutor",
        "hCode": -633333582,
        "lineNumber": 82,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "RemoteWebDriver.java",
        "nativeMethod": false,
        "methodName": "execute",
        "className": "org.openqa.selenium.remote.RemoteWebDriver",
        "hCode": 1767885091,
        "lineNumber": 604,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "RemoteExecuteMethod.java",
        "nativeMethod": false,
        "methodName": "execute",
        "className": "org.openqa.selenium.remote.RemoteExecuteMethod",
        "hCode": 524917802,
        "lineNumber": 35,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "RemoteKeyboard.java",
        "nativeMethod": false,
        "methodName": "sendKeys",
        "className": "org.openqa.selenium.remote.RemoteKeyboard",
        "hCode": -2100038099,
        "lineNumber": 35,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "EventFiringKeyboard.java",
        "nativeMethod": false,
        "methodName": "sendKeys",
        "className": "org.openqa.selenium.support.events.internal.EventFiringKeyboard",
        "hCode": -833178825,
        "lineNumber": 42,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "SendKeyToActiveElement.java",
        "nativeMethod": false,
        "methodName": "call",
        "className": "org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement",
        "hCode": -1406393082,
        "lineNumber": 56,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "SendKeyToActiveElement.java",
        "nativeMethod": false,
        "methodName": "call",
        "className": "org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement",
        "hCode": -1406393107,
        "lineNumber": 31,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "FutureTask.java",
        "nativeMethod": false,
        "methodName": "run",
        "className": "java.util.concurrent.FutureTask",
        "hCode": -820313554,
        "lineNumber": 266,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "DefaultSession.java",
        "nativeMethod": false,
        "methodName": "run",
        "className": "org.openqa.selenium.remote.server.DefaultSession$1",
        "hCode": -255143467,
        "lineNumber": 176,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "ThreadPoolExecutor.java",
        "nativeMethod": false,
        "methodName": "runWorker",
        "className": "java.util.concurrent.ThreadPoolExecutor",
        "hCode": -1285150184,
        "lineNumber": 1142,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "ThreadPoolExecutor.java",
        "nativeMethod": false,
        "methodName": "run",
        "className": "java.util.concurrent.ThreadPoolExecutor$Worker",
        "hCode": -242190645,
        "lineNumber": 617,
        "class": "java.lang.StackTraceElement"
      },
      {
        "fileName": "Thread.java",
        "nativeMethod": false,
        "methodName": "run",
        "className": "java.lang.Thread",
        "hCode": -82946320,
        "lineNumber": 745,
        "class": "java.lang.StackTraceElement"
      }
    ],
    "suppressed": [],
    "message": "sendKeysToActiveElement\nBuild info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'\nSystem info: host: 'z-industries.local', ip: '192.168.10.112', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_102'\nDriver info: driver.version: RemoteWebDriver",
    "hCode": 1522182515,
    "class": "org.openqa.selenium.UnsupportedCommandException",
    "buildInformation": {
      "buildRevision": "5234b32",
      "buildTime": "2017-03-10 09:04:52 -0800",
      "releaseLabel": "3.3.1",
      "hCode": 1563919520,
      "class": "org.openqa.selenium.internal.BuildInfo"
    },
    "screen": null
  },
  "class": "org.openqa.selenium.remote.Response",
  "status": 9
}

Veith Zäch

unread,
Apr 13, 2017, 3:03:48 AM4/13/17
to Selenium Users
I seems that firefox behaves correctly (according to the specs https://w3c.github.io/webdriver/webdriver-spec.html#element-send-keys)

There is no definition for an endpoint like 

POST/session/{session id}/keys

It is implemented in IE, chrome.  

Workaraound/Solution:

Use this endpoint instead:
POST/session/{session id}/element/{element id}/valueElement Send Keys


shivan...@tothenew.com

unread,
May 12, 2017, 9:21:29 AM5/12/17
to Selenium Users
Thanks Dollar, it worked by adding
System.setProperty(
FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"false");


On Friday, March 31, 2017 at 9:48:11 AM UTC+5:30, kfauto13 wrote:

parshuAutomater

unread,
May 30, 2018, 1:01:23 AM5/30/18
to Selenium Users
Hi ,
    I am using latest gecko driver 0.20.1 with firefox version 60.0.1  on Mac OSX 10.12
Python version is 2.7 ,selenium version 3.5
I want to send keys 'cmd+v' on firefox ,its not working .
It was working earlier with older selenium and Firefox versions.
Does any body aware of the issue ,if yes do you know any solution /workaround for this.

Thanks and Regards,
Parashuram
Reply all
Reply to author
Forward
0 new messages