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

Mac command key should be recognized as a modifier key #3101

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

Mac command key should be recognized as a modifier key #3101

lukeis opened this issue Mar 3, 2016 · 3 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3101

What steps will reproduce the problem?
1. Have a simple test that includes the following code (in an attempt to make a new
tab in Firefox; whether this in itself is recommended or not is irrelevant to the issue
in question, but I would like to hear feedback if there is any)

        new Actions(this.driver)
        .keyDown(Keys.COMMAND)
        .sendKeys("t")
        .keyUp(Keys.COMMAND)
        .perform();

where this.driver is an instance of FirefoxDriver, Actions is org.openqa.selenium.interactions.Actions
and Keys is org.openqa.selenium.Keys.

2. Run the test

What is the expected output? What do you see instead?

I'm expecting that a new tab opens in Firefox. Instead, I get a failed tests, with
a new IllegalArgumentException("Key Down / Up events only make sense for modifier keys.")
thrown from inside org/openqa/selenium/interactions/internal/SingleKeyAction.java

The apple command key should be a valid modifier key, but the enum in the aforementioned
class only defines shift, ctrl and alt as modifier keys.

Selenium version: 2.14.0
OS: Mac OS X 10.7.2
Browser: Firefox
Brower version: 8.0.1

Here's a diff that fixes this issue:

java/client/src/org/openqa/selenium/interactions/internal/SingleKeyAction.java
Index: java/client/src/org/openqa/selenium/interactions/internal/SingleKeyAction.java
===================================================================
--- java/client/src/org/openqa/selenium/interactions/internal/SingleKeyAction.java  (revision
15246)
+++ java/client/src/org/openqa/selenium/interactions/internal/SingleKeyAction.java  (working
copy)
@@ -28,7 +28,7 @@
  */
 public abstract class SingleKeyAction extends KeysRelatedAction {
   protected final Keys key;
-  private static final Keys[] MODIFIER_KEYS = {Keys.SHIFT, Keys.CONTROL, Keys.ALT};
+  private static final Keys[] MODIFIER_KEYS = {Keys.SHIFT, Keys.CONTROL, Keys.ALT,
Keys.COMMAND};

   protected SingleKeyAction(Keyboard keyboard, Mouse mouse, Keys key) {
     this(keyboard, mouse, null, key);

Reported by azolotkov on 2011-12-21 13:02:45

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2011-12-26 06:34:32

  • Labels added: Component-WebDriver, OpSys-OSX

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Keys.COMMAND is recognized as a modifier (I was just running some copy+paste tests with
it yesterday).  There are two things preventing you from seeing your desired behavior:

1. OSX does not support native key events, so the FXDriver simulates all key presses.
This means the key press is contained within the "content" window, so the browser probably
never sees the COMMAND+T as it would from a native event.

2. This is actually more important than 1... we disable tabbed browsing for the FirefoxDriver
so window switching could work.  We could support tabbed browsing, but no one has ever
updated the code.

Reported by jmleyba on 2011-12-28 16:57:12

  • Status changed: WontFix
  • Labels added: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
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