mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.11k stars 1.52k forks source link

keyDown(Keys.SHIFT) not considered for sendKeys() #944

Open codingphil opened 6 years ago

codingphil commented 6 years ago

System

Testcase

After calling Actions.keyDown(Keys.SHIFT) it is expected that the following sendKeys() call considers the pressed SHIFT key and uppercases all lower case characters passed to sendKeys() but actually the pressed SHIFT key is just ignored. See the Selenium JUnit test below.

  @Test
  public void testKeyDownShift_sendKeys_keyUpShift_textIsUppercase() {
    // given
    webDriver.navigate().to("http://localhost/SimpleTextField.html");
    WebElement textFieldElem = webDriver.findElementByName("textfield");
    assertEquals("", textFieldElem.getAttribute("value"));
    textFieldElem.click();

    // when
    new Actions(webDriver).keyDown(Keys.SHIFT).sendKeys("abc").keyUp(Keys.SHIFT).perform();

    // then
    assertEquals("ABC", textFieldElem.getAttribute("value")); // <<=== FAILS
  }

Stacktrace

org.junit.ComparisonFailure: expected:<[ABC]> but was:<[abc]>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at SendKeysTests.testKeyDownShift_sendKeys_keyUpShift_textIsUppercase(SendKeysTests.java:439)

Trace-level log

geckodriver-log.txt

codingphil commented 6 years ago

The used HTML page: SimpleTextField.html.zip

mjzffr commented 6 years ago

I was able to reproduce this.

Strangely enough, Marionette does synthesize events that look right (i.e. the shift property on the event object is true when we expect it to be true) but that doesn't actually cause the browser to produce capitalized letters in the input field, apparently. =/

Details at: https://bugzilla.mozilla.org/show_bug.cgi?id=1405370

Trucnt commented 6 years ago

We have faced the same issue.

whimboo commented 6 years ago

As long as the before-mentioned bug is not fixed, it doesn't help us when you add me too comments. Thanks.