truncated keys using element.sendKeys with requireWindowFocus=true

46 views
Skip to first unread message

Praveen Tiwari

unread,
Apr 10, 2020, 10:55:19 AM4/10/20
to Selenium Users
IE driver version : 3.150.1.0, 32 bit
OS: WIN10
Browser: IE11, build: 11.719.18362.0

I'm slightly puzzled whether to use capability requireWindowFocus, I know when setting it to true, driver uses windows SendInput() api for advance interactions utilising mouse and keyboard but it looks like the api is not much reliable.
If I set it to true and use element.sendKeys, each and every time keys get truncated. For instance, if I send "apple", sometimes only 'a' or 'app' is being sent. The trace log show correct actions for each character (keydown and keyup) and after sending all characters it tells 'command execution for sendKeys complete'.

I read Jim's response to this github issue here https://github.com/seleniumhq/selenium/issues/805#issuecomment-396581314 and understand the problem is in IE itself, in next comment Jim tells he has applied a fix so that SendInput() is still used but one keystroke is sent at a time (v3.12.0.4 https://github.com/SeleniumHQ/selenium/blob/master/cpp/iedriverserver/CHANGELOG). I see, what he says exactly what is happening per trace logs but the problem still persist. The browser acts like it has fewer characters in queue than given, types them and innocently goes to the next step as if everything is alright, no exception no warning, nothing.

If I set requireWindowFocus to false, sendKeys seems to be working just fine (looks slower though). I am struggling to find out where to go, should I use requireWindowFocus or not. If I don't use it, I leave out some of the native capabilities of driver, If I use it, the very important action of sending keys doesn't work.

Could someone please guide through and tell If I am missing something? I have run tons of tests and never was able to get sendKeys work with requireWindowFocus=true. I did a different test where I sent keys to a form with a TAB after each string so that all boxes in form gets filled. When requireWindowFocus=true is used, the first box is typed into, a TAB keys is correctly sent and it blows out and leaves rest of the strokes and boxes. When I set requireWindowFocus=false, all TAB keys goes correctly and all form text boxes gets filled (this particular string-TAB combination was extremely slow though).

Thanks very much
- Praveen
Reply all
Reply to author
Forward
0 new messages