SeleniumHQ / selenium-google-code-issue-archive

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

Selenium 2.35 sending wrong keycode when sending exclamation mark character. #6411

Open lukeis opened 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 6411

I am using selenium 2.35 for python and Firefox 23 and I got the following code in selenium
script.

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("www.yahoo.com")
element = driver.find_element_by_id("Some element")
element.send_keys("!")

but when I call to send key "!" to the textbox on the browser, I notice it was actually
sending javascript keynode 16(javascript keynode for shift key) and 39 (javascript
keynode of page up) which is equivalent to "Pageup" key on the keyboard.
This action should have sent keycode 16 and 49( javascript keynode for key "1") which
simulate key action of shift key + 1 which is "!" character.  
This gives me a problem as I am testing product that if pageup button is pressed, it
will trigger the warning message popup and I don't want to trigger this popup by calling
send_key("1").

Reported by takatake2002 on 2013-10-15 20:11:37

lukeis commented 8 years ago

Reported by barancev on 2013-10-16 06:18:45

lukeis commented 8 years ago
I'm seeing something similar (sendKeys sends a '!' character, but it does not appear
in the target field) with Selenium 2.44.0 and Firefox 35.0.1 (on Mac OS 10.8.5 if that
matters). I'll try to make a small test case which reproduces the problem.

Reported by matthew.sheppard on 2015-02-23 06:01:15

lukeis commented 8 years ago
Seems to somehow be page specific, but I haven't identified how yet. For now, I can
reproduce the problem with...

    public static void main(String[] args) throws IOException {
        WebDriver driver = new FirefoxDriver();

        driver.get("http://search-au.funnelback.com/s/search.html?collection=funnelback_documentation");

        WebElement queryBox = driver.findElement(By.id("query"));

        queryBox.sendKeys("!foo");

        String actualValue = queryBox.getAttribute("value");

        if (!actualValue.contains("!")) {
            System.out.println("Value was not set as expected - Was '" + actualValue
+ "'");
        }

        driver.quit();
    }

Reported by matthew.sheppard on 2015-02-23 06:33:57

lukeis commented 8 years ago
Ok, I think I pinned it down to the combination of jQuery UI's autocomplete with selenium.

This is a small page which reproduces the problem...

<html>
        <head>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
            <script type="text/javascript">
                $(function() {
                    var availableTags = [
                        "Java",
                        "JavaScript"
                    ];

                    $( "#query" ).autocomplete({
                        source: availableTags
                    });
                });
            </script>
        </head>

        <body>
            <input id="query" />
        </body>
    </html>

...with the following code...

        WebDriver driver = new FirefoxDriver();

        driver.get("file:///Users/msheppard/Desktop/test.html");

        WebElement queryBox = driver.findElement(By.id("query"));

        queryBox.sendKeys("!foo");

        String actualValue = queryBox.getAttribute("value");

        if (!actualValue.contains("!")) {
            System.out.println("Value was not set as expected - Was '" + actualValue
+ "'");
        }

        driver.quit();

Hope that's helpful.

Reported by matthew.sheppard on 2015-02-24 22:50:58

lukeis commented 8 years ago
I'm seeing the same issue with "&" and "("

Reported by sahokoh on 2015-02-28 00:29:49

lukeis commented 8 years ago
I occurrered for me, with "!", "("

I used ruby version of webdriver(2.45.0).

Reported by takaidohigasi on 2015-02-28 17:06:41

lukeis commented 8 years ago
Code I worked is as follows
https://github.com/takaidohigasi/selenium_demo/blob/develop/bin/ruby_warrior_demo.rb

Reported by takaidohigasi on 2015-02-28 17:10:53

lukeis commented 8 years ago

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