selenium: sendKeys in InternetExplorerDriver doesn't always send keys

We stumbled over the seldom occuring issue that InternetExplorerDriver won’t enter some text into text fields, leaving them blank.

To reproduce and isolate the problem, I’ve created a small Selenium/Java script that simply enters increasing numbers into a text field and asserts the value of the HTML tag, for 30 minutes. After a few seconds or minutes, the text field stays empty and the assertion fails; my expectation is, of course, that sendKeys will send keys on every invocation, or at least throws an exception if there is a problem. Most of the time, we are able to reproduce the problem with this method before we reach 300 - the longest we had to wait was until 839.

In this case, I’m reading the value of the input field immediately after calling sendKeys, but even when looking at the browser after the assertion, the characters won’t appear, so I don’t believe it’s a timing issue.

Both Selenium and IEDriver are at version 2.45.0, and we could reproduce it on a machine with Win7 + IE8, and on another one with Win7 + IE11, although it’s rarer on IE11 (meaning it takes longer until it happens) Windows is 64bit, IE and IEDriver are 32bit. We are using Java 1.8.0_51 (x64)

It seems that requireWindowFocus = true is relevant.

Since I haven’t found anything about this problem on the internet, are we the only ones having these troubles?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

There is no way for the IE driver to fix this problem. None. Full stop. In this case, the driver is using the Windows SendInput API to simulate keystrokes. This API inserts the keystrokes directly into the hardware input queue for the keyboard, so there is no discernible difference from an application’s point of view from those keystrokes being simulated by SendInput or actually from the user’s keyboard.

After calling SendInput, the driver waits to see if the expected number of keyboard events have been fired. In the instance where the sendKeys fails, the browser is not processing the keystrokes fully. If IE isn’t processing the keyboard input properly, there’s nothing the driver can do about it.

Folks are welcome to inspect and audit the code to validate that the IE driver is using it correctly, and that it’s properly waiting on the processing of events.

I’m also getting issues where the case is changed. I’m using sendKeys(“Test”) and every so often it is typing “test” instead. This only happens with IE11, Chrome and Firefox (and even IE10) are all fine.

Is there any appetite to fix this? It basically renders our IE11 tests useless as they’re so flaky.