Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send_keys fails to send left parenthesis in Firefox in some cases #674

Closed
csims opened this issue Jun 16, 2015 · 6 comments
Closed

Send_keys fails to send left parenthesis in Firefox in some cases #674

csims opened this issue Jun 16, 2015 · 6 comments

Comments

@csims
Copy link

csims commented Jun 16, 2015

Using the Ruby bindings with Firefox 38.0.5 and selenium-webdriver gem version 2.46.2, I'm unable to send left parentheses in some cases (ex: on google.com it works, on webjet.com it doesn't). I've reproduced the issue in Windows 7 64-bit and OS X 10.10.3, and with Ruby 1.9.3 and 2.2.2, with the below example test case, which worked with selenium-webdriver -v 2.44 and Firefox 33 (before native events went away):

require 'selenium-webdriver'
browser = Selenium::WebDriver.for :firefox
browser.navigate.to "http://webjet.com"
element = browser.find_element(:id, 'CityTo')
element.send_keys "(BOS)"

Expected: text field should fill with "(BOS)"
Actual: text field fills with "BOS)"

@ddavison
Copy link
Member

so, i can reproduce this issue, but I'm not sure that this is a Selenium issue.. this seems like it could be the Webjet website doing some javascript stuff and taking it out?

@crusaders-vsct
Copy link

Hello,

We have exactly the same issue with :

  • Windows 7 64-bit
  • Firefox 38.0
  • "Selenium dependencies" (webdriver, java, firefox-driver, etc.) in version 2.46.0

The left parenthesis is not send (caused by synthetic events ?).

With Firefox 33.0 and dependencies in 2.44.0 (native events), the problem is not present. But if we activate the synthetic events, the problem is reproduced.

This issue is not reproduced on chrome.

For now, we have “fixed” this with this work around (found on https://code.google.com/p/selenium/issues/detail?id=1723#c12) :

String myTextToSend = “Hello (World)”.replaceAll("\\(", Keys.chord(Keys.SHIFT, "9")):
WebElement.sendKeys(myTextToSend);

However when this code is executed with native events on Firefox 33, the character "9" is written (instead of '(' ).

@florentbr
Copy link

It is reproducible on Wikipedia.
It occurs when an input field is enhanced with some JavaScript to produce the auto-complete.
This issue doesn't occur with the Chrome, IE and PhantomJS driver.

Environment:
Windows 8.1, Firefox 40.0.2, Selenium 2.27.1

To reproduce (Python):

import selenium
from selenium import webdriver
wd = webdriver.Firefox()
wd.get("https://en.wikipedia.org/wiki/Main_Page")
ele = wd.find_element_by_id("searchInput")
ele.send_keys("a(b)c")
assert "a(b)c" == e.get_attribute('value')

@ddavison
Copy link
Member

thanks for doing that research @florentbr 👍 I had a feeling something like that might've been happening.

I'm still not sure if we are going to do anything about this.

@lukeis
Copy link
Member

lukeis commented Nov 5, 2015

so... after spending some time trying to trace this down... it appears the javascript on a page (at least to Firefox and in particular the nsIDOMWindowUtils.sendKeyEvent() ) calls event.preventDefault when the keydown event for "(" is fired.

Now... I could not find it in the javascript on a few pages that reproduced this behavior of the preventDefault actually being called. But then again this sendKeyEvent method is deprecated in favor of nsITextInputProcessor.

I think it would be a good idea to change to this method in > v38 of firefox. Except for the fact that marionette is coming soon (well, it has to for other reasons) and the level of effort to change to using this type of sendKeys model is non-trivial. On top of that, I'm not certain that would even fix the issue entirely.

With that being said... I basically think this issue is going to be in a state of "won't fix" and will eventually be closed when marionette becomes the default driver for Firefox / Selenium.

Workarounds are pretty easy, such as using execute script to set the value of the input up to the '(' character that you want to send, and then using send keys for the remaining text (in order to trigger the proper events)

@barancev
Copy link
Member

barancev commented Aug 3, 2017

It's time to close this issue, geckodriver is the default and it passes this test.

(But I should note that legacy driver passed it too on both mentioned sites, wikipedia and webject :))

@barancev barancev closed this as completed Aug 3, 2017
@lock lock bot locked and limited conversation to collaborators Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants