Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Clicking the link while holding down shift (using Actions), on Windows, does not open a new window #3734

Closed
lukeis opened this issue Mar 3, 2016 · 52 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3734

Problem:
Actions Chain 'Pressing a key -> clicking the link -> releasing the key' behaves as
there is no pressing a key.

Steps to reproduce (run following script in Python):
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://seleniumhq.org/")
element = driver.find_element(By.LINK_TEXT,"Selenium WebDriver")
action = ActionChains(driver)
action.key_down(Keys.CONTROL).click(element).key_up(Keys.CONTROL).perform()

Expected result: Link is opened in a new tab (this is default behavior of FF - when
you click the link within pressing CTRL, it opens a new tab)
Actual result: Link is opened in the same tab, and there are no warnings/exceptions
that smth went wrong.

Selenium version: WebDriver 2.20.0, Python 2.7
OS: Windows 7
Browser: Any (Mozilla Firefox for given example)
Browser version: Any (Firefox 10.0.2 for given example)

[The issue was first faced with custom web-app where click is supposed to open one
window, and CTRL+click is supposed to open another window, but indeed within WebDriver
CTRL+click opens the same window as just regular click. For a sake of simplicity I'm
giving standard FF example here, but let me know if you need more details.]

Reported by 2olesya.baranova on 2012-04-16 13:18:51

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Problem was solved by using Robot in Java:
new Robot().keyPress(KeyEvent.VK_CONTROL);
driver.findElement(...).click();
new Robot().keyRelease(KeyEvent.VK_CONTROL);

and by using win32api in Python:
win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
driver.find_element(...).click()
win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_EXTENDEDKEY | win32con.KEYEVENTF_KEYUP,
0)

however, would still like to know why it's not working with WebDriver Advanced User
Interactions (there is a possibility that I'm using them incorrectly - please, advice
then on a usage - thanks!).

Reported by 2olesya.baranova on 2012-04-16 13:23:00

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Does the same thing happen on Linux? If not, it could be a duplicate of 3722.

Reported by eran.mes on 2012-04-16 14:56:52

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I've tried on Xubuntu Linux (using FF11, selenium java binding and and openjdk-6) --
the same result. Neither Keys.CONTROL nor Keys.SHIFT allow to open link in a new window/tab.
The modifier seems to be ignored.

Reported by barancev on 2012-04-18 11:25:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3425 has been merged into this issue.

Reported by barancev on 2012-05-05 14:23:28

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3010 has been merged into this issue.

Reported by barancev on 2012-05-05 14:23:53

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3080 has been merged into this issue.

Reported by barancev on 2012-05-05 14:25:53

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3201 has been merged into this issue.

Reported by barancev on 2012-05-05 14:26:42

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

To clarify: something like this may only work on platforms where we support native events
(not Mac). Additionally, WebDriver never supported multiple tabs on Firefox - If my
memory serves me right, there's  code to prevent them from being created.

Reported by eran.mes on 2012-05-09 18:41:25

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3511 has been merged into this issue.

Reported by barancev on 2012-05-11 05:39:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2012-05-25 14:07:36

  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3963 has been merged into this issue.

Reported by barancev on 2012-05-25 14:08:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3950 has been merged into this issue.

Reported by barancev on 2012-05-25 16:38:00

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

shift+click definitely doesn't work using synthetic events for Firefox (FF12).

See:
https://code.google.com/p/selenium/source/browse/trunk/javascript/webdriver/test_e2e/actionsequece_test.html#315

In particular:
https://code.google.com/p/selenium/source/browse/trunk/javascript/webdriver/test_e2e/actionsequece_test.html#338

Reported by jmleyba on 2012-06-08 21:52:47

  • Status changed: Accepted

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Starting to look into that now.

Reported by eran.mes on 2012-06-26 09:14:16

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Update: A small test I've written shows that on Linux, with native events enabled, shift+click
opens a new window and control+click opens a new tab (although there's to way to write
a test for that, since WebDriver does not support tab-switching at the moment).
This can be achieved by two ways:
    new Actions(driver)
        .keyDown(Keys.CONTROL)
        .click(link)
        .keyUp(Keys.CONTROL)
        .perform();
And:

    new Actions(driver)
        .moveToElement(link)
        .keyDown(Keys.SHIFT)
        .click()
        .keyUp(Keys.SHIFT)
        .perform();

I'll check the Python version works as well.

Reported by eran.mes on 2012-06-26 10:01:48

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I see this issue is on Windows. Modifiers work as expected on Linux.

See 
http://code.google.com/p/selenium/issues/detail?id=3963
for another test case.

Reported by AshwinPrabhuB on 2012-06-26 10:27:26

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Added a test in r17278 to demonstrate it does work on Linux.

Reported by eran.mes on 2012-06-26 12:17:41

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 3201 has been merged into this issue.

Reported by eran.mes on 2012-06-28 09:03:34

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Jason, have you got an idea on how to make it work with synthesized events?

Reported by eran.mes on 2012-06-28 09:05:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I performed some investigation on this issue and figured out that at least at my machine
using PostMessage/SendMessage doesnt work - messages are sent successfully but simply
ignored. Adding waits and modifying of wParam at clickAt by MK_SHIFT/MK_CONTROL didn't
help help too.

As solution i added usage of keybd_event() at sendModifierKeyDown()/sendModifierKeyUp()
for these 3 modifiers SHIFT/CONTROL/ALT - it works for me. I created and attached patch
- please review.

Also i didn't try SendInput - maybe it's more suitable solution than keybd_event()
calls.

Reported by a.u.savchuk on 2012-06-30 22:14:59


- _Attachment: [Modifiers_issue3734.patch](https://storage.googleapis.com/google-code-attachments/selenium/issue-3734/comment-20/Modifiers_issue3734.patch)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks for the patch, but keep in mind that using SendInput(), while the "right" solution,
would force us to require the target window to have focus. It (and its predecessors
keybd_event() and mouse_event()) push input at a very low level in the stack, and whatever
window has the focus will get the corresponding mouse or keyboard events. If we want
to go down that road, I'm game, but in the past, we've always placed a premium on being
able to have the target window *not* be focused, and it'll take a fair amount of rearchitecture
to handle focusing the right window, particularly for multiple driver instances, and
multiple windows of a single driver instance.

Reported by james.h.evans.jr on 2012-06-30 23:58:30

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks for comment. Ok, i got the point.
I agree, my patch isn't real solution, it's just a workaround for problem with clicking
at link with shift/cntl/ pressed.
Entering text and so on with these modififiers, i think, may not work properly. Also
this patch will leads to incorrect behaviour in case of multiple webdriver instances
are run.

I'll continue searching of correct solution.

Reported by a.u.savchuk on 2012-07-01 17:53:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

We are also facing the issue mentioned in http://code.google.com/p/selenium/issues/detail?id=3950
with ExtJS UI.

Reported by mmlk09 on 2012-08-27 07:05:20

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have found this problem to reoccur in Firefox 15 and Firefox 16. I have a test that
is selecting multiple items in an ExtJS control:

               action = ActionChains(self.driver)
               action.key_down(Keys.CONTROL)
               action.click(el)
               action.key_up(Keys.CONTROL)
               action.perform()

On Firefox 13 and 14, it behaves correctly. On Firefox 12, 15, and 16, I have seen
the click register as an unmodified click, causing the test to fail.

Reported by lex.spoon@logicblox.com on 2012-09-04 21:07:30

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This comment is very timely, r18424 introduced a new capability "requireWindowFocus"
that should allow to fix this issue. Please be patient, we're not totally careless
:)

Reported by barancev on 2013-01-10 18:40:16

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

That sounds nice :)

Reported by lyubobg on 2013-01-11 09:22:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Am doing testing on MAC Chrome and same thing, click invokes a click even with the CONTROL
key invoked.... driving me nuts...  Content_Click worthless....

I've tried every work around I can find on the web, nothing... works

Hope it gets fixed soon. Thanks

Best
Mark Heilman
Billings, MT

Reported by mark.heilman on 2013-06-12 13:18:06

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by eran.mes on 2013-06-18 12:51:41

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I could see the problem in Firefox 21 with Selenium 2.33.

Timely resolution would help.

Regards,
Veera

Reported by raghavan.seshadri on 2013-06-27 13:13:28

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Same issue but with LEFT-ALT + CLICK, in Firefox 21 with Selenium 2.33.

This works with Chrome 28.

What is it with all those FF-specific bugs and Selenium?


Reported by ascarel on 2013-07-08 20:43:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Seeing this as well for a Ctrl + Click operation to multiply select items in a list.

IE9, Selenium 2.33.

Thanks.

Reported by JCDClark on 2013-07-11 16:08:28

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi. This issues is reproducible with Ctrl + click on selecting multiple items on a table
using selenium 2.33 and IE 8. 

Reported by chitaniulianliviu on 2013-07-31 14:23:09

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Is this issue still actual?
http://screencast.com/t/vTxiVSjMd

Reported by barancev on 2013-08-24 10:31:21

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Still experiencing this issue with Selenium 2.35, IE9 and Firefox 23

Reported by nicolas.valera@calgaryscientific.com on 2013-09-05 14:36:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Still experiencing this issue with Selenium 2.35 and Firefox 23 on Windows 7. Is there
a road map for resolution?

Reported by amaury.rodriguez on 2013-09-23 15:58:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Someone should provide a new reproduction case, otherwise the issue will be closed.

Reported by barancev on 2013-11-01 19:38:04

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue still happens on Firefox 23 and selenium 2.35

Reported by likZhang on 2013-12-06 20:08:47

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Closing the issue as noted in comment 38. Please provide a new reproduction case if
asking for reopening.

Reported by barancev on 2014-01-02 17:42:32

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

What is the problem?
Cannot execute clicks in a action chain with a modifier key like SHIFT pressed on IE
and Firefox WebDrivers on Windows. Modifier keys work in ChromeDriver and FirefoxDriver
with native events enabled on Linux (not on Windows).

What steps will reproduce the problem?
Try this code snippet on MS Windows:

WebDriver driver = new InternetExplorerDriver(); // or new FirefoxDriver(fp) with fp.setEnableNativeEvents(true);


//WebDriver driver = new ChromeDriver(); - This works!
driver.get("http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/list-view.html");

WebDriverWait wait = new WebDriverWait(driver, 25);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("gridpanel-1009")));

new Actions(driver)
   .keyDown(Keys.SHIFT)
   .click(driver.findElement(By.xpath("//table/tbody/tr[4]")))
   .click(driver.findElement(By.xpath("//table/tbody/tr[8]")))
   .keyUp(Keys.SHIFT)
   .perform(); // Should multi select rows in the table


What is the expected output? What do you see instead?
Should have selected multiple rows in the table. Instead I can see 2 separate row clicks
and only last row remains selected (since SHIFT had no effect).

Selenium version: 2.20.0
OS: Windows 7 (64 bit)
Browser: Internet Explorer 9, Firefox (tried 3.5, 5, 9) on Windows

Reported by AshwinPrabhuB on 2014-01-03 06:27:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have also been experiencing problems with this issue, and can make a direct parallel
between Linux (where it works) and Windows 7 (where it does not).

I am using a remote webdriver via a grid set up.

My node is running on a Windows 7 Enterprise, Version 6.1 (Build 7601:SP1)
OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.24.1.10.4.el5-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
Firefox version is ESR 10.0.3

Code:
Actions builder = new Actions(driver);
builder
    .keyDown(Keys.CONTROL)
    .click(driver.findElement(By.xpath(target)))
    .keyUp(Keys.CONTROL);
Action selectMultiple = builder.build();
selectMultiple.perform();

LINUX test:
My hub is on GNU/Linux 2.6.32-220.13.1.el6.x86_64 running:
OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.24.1.10.4.el5-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode) 

Code executes on the Linux host without any problems.  Remote session shows multi-select
behaviour indicating that the control key is being held down during each click.

WINDOWS test:
My Hub is now on the same Windows 7 system as my node.  I repoint my node to the new
hub.

Code executes on the Windows host without any problems, however the session does not
show multi-select behaviour indicating that the control key is NOT being held down
during each click.

----

Is this a JVM implementation/platform related issue?

Please let me know if you need any further information.

Reported by grant.gw.wilcox on 2014-02-20 16:04:23

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

*Edit* Cut and paste error - 

My Windows 7 box is actually running this Java:
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

Reported by grant.gw.wilcox on 2014-02-20 16:08:10

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi, there, I checked the latest Selenium Webdriver 2.40 but looks like this fix is not
included, will it be included in the next release?

Regards


Reported by songqipro on 2014-03-12 09:35:49

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi, there too, is there a future for this bugfix?
Thanks.

Reported by renanborges02 on 2014-03-26 19:30:45

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

For all those still struggeling with this problem, I could get it work by explicitely
disabeling native events for Firefox:

FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(false);

then use the usual way with:
Actions actionProvider = new Actions(driver);
Action ctrlClick = ActionProvider.keyDown(Keys.CONTROL).click(element).keyUp(Keys.CONTROL).build();
ctrlClick.perform();

Tested with Windows 7, Firefox 28, Selenium 2.41

Reported by schmiddd on 2014-05-05 13:04:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This appears to still be an issue on WebDriver 2.43.0 against Firefox 31 (ESR). Attached
a simple test case which reproduces this locally on Windows 7 - webdriver_control_click_bug.py


Also attached another test case using the w3.org tool to check keyboard events which
shows that although the control click is being pressed it is being ignored - webdriver_control_click_bug_2.py

Reported by stevejeffers on 2014-09-18 15:41:50


- _Attachment: [webdriver_control_click_bug_2.py](https://storage.googleapis.com/google-code-attachments/selenium/issue-3734/comment-47/webdriver_control_click_bug_2.py)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Re-attached webdriver_control_click_bug.py for comment #47

Reported by stevejeffers on 2014-09-18 15:44:20


- _Attachment: [webdriver_control_click_bug.py](https://storage.googleapis.com/google-code-attachments/selenium/issue-3734/comment-48/webdriver_control_click_bug.py)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue still present in Selenium 2.44.0

Plz fix this soon..

Reported by rakeshranjan1985 on 2015-05-02 05:47:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by jmleyba on 2015-05-02 23:04:26

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

this is also blocking us within IE:
* select multiple rows works fine for FF and Chrome but not in any IE version ... :-/

code:
WebElementFirstRow.click();
Robot().keyPress(KeyEvent.VK_CONTROL);
WebElementSecondRow.click();
Robot().keyRelease(KeyEvent.VK_CONTROL);

The elements I try to click is are rows within an extJS Grid which has multi selectable
rows

Reported by dietmar.lienhart on 2015-05-04 12:24:11

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:15:15

  • Labels added: Restrict-AddIssueComment-Commit

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

1 participant