ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Keyboard.sendKeys(Keys.chord()) is ignored silently #987

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Try sending ALT+F4 and notice that it will be ignored. Other chord operations 
are ignored as well, as shown by bug #743.

To reproduce, run: driver.getKeyboard().sendKeys(Keys.chord(Keys.ALT, Keys.F4));

Original issue reported on code.google.com by cow...@bbs.darktech.org on 3 Dec 2014 at 1:23

GoogleCodeExporter commented 9 years ago
This is a major problem. Duplicate issues: #572, #581, #743, #972

Possible duplicate: #919

I am using Chromedriver version 2.44.0 (java), 2.12 (native). Chrome version 
39.0.2171.71.

Original comment by cow...@bbs.darktech.org on 3 Dec 2014 at 2:32

GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 3 Dec 2014 at 7:02

GoogleCodeExporter commented 9 years ago
your test program may not be correct.

 driver.getKeyboard().sendKeys(Keys.chord(Keys.ALT, Keys.F4));

please refer Issue 743

let me know if can close the issue.

Original comment by andrewch...@chromium.org on 8 Dec 2014 at 7:41

GoogleCodeExporter commented 9 years ago
Andrew,

Seeing as I am running the same versions as you, I am willing to bet this issue 
is platform-specific. I am running under Windows 7, 64-bit with Chrome 39 
(64-bit). I assume you are running under Linux or OSX?

Can you try the same platform as me and see if you can reproduce the problem?

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 9:35

GoogleCodeExporter commented 9 years ago
for Issue 743,  I am running under Windows 7 as well.
Do you have complete test case so that I can see the result?

Original comment by andrewch...@chromium.org on 8 Dec 2014 at 10:18

GoogleCodeExporter commented 9 years ago
I just confirmed on my end, this code fails under Windows 7, native driver 
2.12, Chrome 39.0.2171.71:

WebElement tempElement = driver.findElement(By.cssSelector("body"));
tempElement.click();
tempElement.sendKeys(Keys.chord(Keys.ALT, Keys.F4));

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:33

GoogleCodeExporter commented 9 years ago
Andrew,

I'll try producing a self-contained Maven testcase. Where do I send it?

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
#6 is enough for me
please provide
driver.get("  your web site ");

and what  result you are  expecting?

Original comment by andrewch...@chromium.org on 8 Dec 2014 at 10:37

GoogleCodeExporter commented 9 years ago
Okay, let's try this:

        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeDriverService service = new ChromeDriverService.Builder()
                .usingDriverExecutable(new File("selenium-driver/windows/googlechrome/64bit/2.10/chromedriver.exe"))
                .usingAnyFreePort()
                .build();
        service.start();
        WebDriver driver = new RemoteWebDriver(service.getUrl(), capabilities);
        driver.navigate().to("http://www.google.com/");
        System.out.println("pre-click");
        WebElement tempElement = driver.findElement(By.cssSelector("#gbqfq"));
        tempElement.click();
        System.out.println("post-click");
        tempElement.sendKeys(Keys.chord(Keys.ALT, Keys.F4));
        System.out.println("browser should have shut down");

I am expecting sendKeys() at the second to last line to shut down the browser, 
but nothing happens.

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:40

GoogleCodeExporter commented 9 years ago
Sorry, there is a typo there (in the version number). Hold on.

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:41

GoogleCodeExporter commented 9 years ago
Okay. Switching the code from 2.10 to 2.12 did not help:

                .usingDriverExecutable(new File("selenium-driver/windows/googlechrome/64bit/2.12/chromedriver.exe"))

I get the same output. What do you get on your end?

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:47

GoogleCodeExporter commented 9 years ago
in http://www.google.com,
where should I click and alt-F4 to make it shut down if manually?

Original comment by andrewch...@chromium.org on 8 Dec 2014 at 10:55

GoogleCodeExporter commented 9 years ago
Manually, clicking anywhere and hitting ALT-F4 will shut down the browser. The 
testcase clicks on the input box, but really it could have clicked anywhere 
that does not trigger page navigation.

Original comment by cow...@bbs.darktech.org on 8 Dec 2014 at 10:59

GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 9 Dec 2014 at 7:00

GoogleCodeExporter commented 9 years ago
Andrew,

Does "verified" mean you were able to reproduce the problem on your end? Or 
does it mean you were not able to?

Original comment by cow...@bbs.darktech.org on 9 Dec 2014 at 7:01

GoogleCodeExporter commented 9 years ago
Kinds of - 
with all the Selenium codes you have,  are they  work in any other browsers? 
(those Selenium codes may not work)
but I can only prove CTL-F4 work in other place, but not Chrome
            Actions action = new Actions(driver);
            action.sendKeys(Keys.chord(Keys.ALT, Keys.F4));   // close tab work
            action.perform();
At least,  I  have something to look into.

Original comment by andrewch...@chromium.org on 9 Dec 2014 at 7:55

GoogleCodeExporter commented 9 years ago
Are you saying that ALT-F4 works for you but CTRL-F4 does not? If so, we still 
have a problem to narrow down because ALT-F4 still does not work on my end.

How do we go about narrowing this further?

Original comment by cow...@bbs.darktech.org on 9 Dec 2014 at 8:04

GoogleCodeExporter commented 9 years ago
I verified  my test program  should at least work for   CTRL-F4, and this is 
the benchmark.  once this work,  ALT-F4 may work automatically since they are 
very similar.

Original comment by andrewch...@chromium.org on 9 Dec 2014 at 8:40

GoogleCodeExporter commented 9 years ago
Sounds good.

Let me know once you have an updated build for me to test and I'll happily take 
a look. Thank you.

Original comment by cow...@bbs.darktech.org on 9 Dec 2014 at 8:47

GoogleCodeExporter commented 9 years ago
Sure, I will

Original comment by andrewch...@chromium.org on 9 Dec 2014 at 8:55

GoogleCodeExporter commented 9 years ago
I may not fix this soon.
If you just want to  shutdown browser, there is an alternate way doing it - 
driver.quit()

Original comment by andrewch...@chromium.org on 10 Dec 2014 at 12:43

GoogleCodeExporter commented 9 years ago
driver.quit() is not an option for two reasons:

1. I need to shut down the browser gracefully (driver.quit() kills the process) 
because I need to resume the browser session at a later time (using a custom 
profile directory).
2. Aside from needing to close the browser, Keys.chord() is useful for 
combinations like CTRL-T for opening new/empty tabs.

Original comment by cow...@bbs.darktech.org on 10 Dec 2014 at 12:50

GoogleCodeExporter commented 9 years ago
ok,  let me see what I can do.

Original comment by andrewch...@chromium.org on 10 Dec 2014 at 1:07

GoogleCodeExporter commented 9 years ago
1. We should modify chromedriver so that driver.quit() shuts down the browser 
gracefully if it is using a custom profile directory. Right now it just does a 
kill -9 (on linux/mac).

2. This is a separate set of issues, please star 581 and 1003 if you're 
interested.

Original comment by samu...@chromium.org on 16 Dec 2014 at 10:54

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:19

GoogleCodeExporter commented 9 years ago
This is a limitation in the way we simulate keyboard input in ChromeDriver. 
Keys get sent directly to the render process, bypassing the browser process. So 
any keyboard shortcut handlers in the browser process will not be invoked by 
sendKeys().

Original comment by samu...@chromium.org on 5 Mar 2015 at 10:44