SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

sendKeys sendig ampersand character #6074

Open lukeis opened 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 6074

What steps will reproduce the problem?
1. WebElement element = ...; // is an input text element
2. element.sendKeys("&");
3. element.sendKeys(Keys.getKeyFromUnicode('\u0026'));

It was expected that the character in step 2 and 3 was written on the input element
but it isn't.

Selenium version: 2.33
OS: Ubunto 13.04
Browser: FireFox
Browser version: 23.0

Reported by adelaide.trabuco on 2013-08-09 09:13:12

lukeis commented 8 years ago

Reported by barancev on 2013-08-09 09:36:35

lukeis commented 8 years ago
This may be related to: http://stackoverflow.com/questions/10289022/unable-to-type-ampersand-in-selenium-2

I have experienced this issue as well, however I have noticed that the ampersand fails
to be sent only to certain <input> elements. According to the above link it is only
<input> elements that use an JQuery UI Autocomplete API, and not regular <input< elements.

Steps to Reproduce:
(1). browser.get("http://www.google.com");
(2). browser.findElement(By.name("q")).sendKeys("Send&KeyTest");
(3). Assert.assertTrue(browser.findElement(By.name("q")).getAttribute("value").equals("Send&KeyTest");
(4). browser.get("http://www.amazon.com");
(5). browser.findElement(By.id("twotabsearchtextbox")).sendKeys("Send&KeyTest");
(6). Assert.assertTrue(browser.findElement(By.id("twotabsearchtextbox")).getAttribute("value").equals("Send&KeyTest"));

Expected result:
Both Assert statements should pass, and both search boxes should contain the string
"Send&KeyTest".

Actual result:
The first assert statement passes but the second fails. Specifically the google search
box contains "Send&KeyTest" and the second statement contains "SendKeyTest".

Note that manually typing the ampersand character into the search bar works.

Reported by danielfreer on 2013-08-15 14:14:52

lukeis commented 8 years ago
Also the "(" character is affected. No other special characters appear to be affected.

Reported by danielfreer on 2013-08-21 16:49:24

lukeis commented 8 years ago
I am also seeing this problem via the Geb testing tool that uses WebDriver. When I try
to send a string containing the & character to an input field, the & is removed. I
haven't found a way to escape it to prevent this from happening. I've tried:

\&
\\&
&&

Reported by dan.speck on 2013-11-07 17:06:24

lukeis commented 8 years ago
I also experience the issue using angularjs/protractor on an auto complete input.

Browser: Firefox 29.0 / Firefox 29.0.1
OS: Ubuntu 14.04 / Windows 8
Selenium: 2.41.0 / 2.40.0

Issue: & character is simply omitted in Firefox auto complete inputs.

Works well on a "normal" input (non auto-complete) in Firefox
Works well on any input in: Chrome 34, IE11, IE10.

Reported by leonardogallucci on 2014-05-14 20:32:52

lukeis commented 8 years ago
Any workaround this ?
I am having the same issue as well with Firefox and Protractor.

Reported by balakumaran.g@flipkart.com on 2014-09-17 05:40:14

lukeis commented 8 years ago
Upgraded to FF 33 and now its working.

Reported by andre@mybura.com on 2014-11-09 06:03:28

lukeis commented 8 years ago
This still fails on Linux / FF 33 (and passes in Chrome)

      driver.get 'http://dir.indiamart.com'
      el = driver['search_string']
      el.send_keys '(&)'
      expect(el.attribute('value')).to eq '(&)'

expected: "(&)"
     got: ")"

Reported by titusfortner on 2014-11-17 19:57:43

lukeis commented 8 years ago
My requirement was to type "R&d" in a text field, tried below code and it worked.

    textBox.sendKeys("R/&d")
    textBox.sendKeys(Keys.LEFT);
    textBox.sendKeys(Keys.LEFT);
    textBox.sendKeys(Keys.BACK_SPACE);

Reported by vvenkatarajulu@google.com on 2015-02-26 12:11:09

lukeis commented 8 years ago
I am also seeing this problem with Firefox 31.6.0 and 37.0.1 and selenium 2.45.0 on
Linux when attempting to type into a Select2 control that performs a search as the
user types in to the search box.  I believe it also uses jquery under the hood.  The
problem does NOT occur when using Chromium.

Reported by tbeadle on 2015-06-16 14:13:02

lukeis commented 8 years ago
I just experienced similar problem with tilde ~ character. Using Chrome 43.0.2357.134
m and Selenium 2.45.0 on Windows 8. It just doesn't get sent to text field, all other
special characters from my keybord work fine.

Reported by testowekontoasdf on 2015-07-20 15:10:35

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 17:45:55