-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ctrl not pressed for Ctrl-A (SendKeys of Actions API) #665
Comments
Adding a Keys.NULL at the end does.
|
Why is the behavior different from |
This test fails too with // given
driver.navigate().to(TestPages.SIMPLETEXTFIELDPAGE);
WebElement textFieldElem = driver.findElementByName("textfield");
textFieldElem.click();
new Actions(driver).sendKeys(textFieldElem, "12345").perform();
assertEquals("12345", textFieldElem.getAttribute("value"));
// when
new Actions(driver).sendKeys(Keys.CONTROL, "a", Keys.NULL).perform();
new Actions(driver).sendKeys(Keys.DELETE).perform();
// then
assertEquals("", textFieldElem.getAttribute("value")); |
I’m sorry, it’s not clear to me from the comments so far in this thread what the problem actually is. I have some questions:
|
In general Both test cases mentioned in the comments above fail. Interestingly the following code without using the Actions API does work (without using // given
webDriver.navigate().to(TestPages.SIMPLETEXTFIELDPAGE);
WebElement textFieldElem = webDriver.findElementByName("textfield");
textFieldElem.click();
textFieldElem.sendKeys("12345");
assertEquals("12345", textFieldElem.getAttribute("value"));
// when
List<CharSequence> keyWithModifiers = new ArrayList<CharSequence>();
keyWithModifiers.add(Keys.CONTROL);
keyWithModifiers.add("a");
String ctrlA = Keys.chord(keyWithModifiers);
textFieldElem.sendKeys(ctrlA);
textFieldElem.sendKeys(Keys.DELETE);
// then
assertEquals("", textFieldElem.getAttribute("value")); |
Same issue on newer gecko driver. PLATFORM CODE
EXPECTED ACTUAL LOG EXTRACT
codingphil workaround also works for me. |
Could someone test if that is still a problem with Firefox 58 beta, or 59 Nightly? |
The test is still failing with Firefox 58 Beta and Firefox 59 Nightly, geckodriver 0.19.1 and selenium 3.8.1. |
I don't know which kind of code you were running for the trace from the last comment. Can you please highlight the part of the trace log which shows the problem? |
The code from the original bug entry: // given
driver.navigate().to("http://localhost/SimpleTextField.html"); // TODO: Adapt to your own local server
WebElement textFieldElem = driver.findElementByName("textfield");
textFieldElem.click();
new Actions(driver).sendKeys(textFieldElem, "12345").perform();
assertEquals("12345", textFieldElem.getAttribute("value"));
// when
List<CharSequence> keyWithModifiers = new ArrayList<CharSequence>();
keyWithModifiers.add(Keys.CONTROL);
keyWithModifiers.add("a");
String ctrlA = Keys.chord(keyWithModifiers);
new Actions(driver).sendKeys(textFieldElem, ctrlA).perform();
new Actions(driver).sendKeys(Keys.DELETE).perform();
// then
assertEquals("", textFieldElem.getAttribute("value")); // <<=== FAILS The problem is that the assert fails (no error in trace). I just added the trace if anybody needs the info. |
Now I see. This looks indeed strange in the trace:
The Ctrl keys gets released before pressing |
I assume code like the following will work, right?
It should make it a dupe of issue #1112. |
Interesting is that the following code works fine.
So is the chord wrong here too? |
Which code works fine? The one I posted in my last comment? Have you run that? If it works (which I believe it does) this issue is invalid, and you should file a bug for your used binding. |
My argument was that in the code posted above (#665 (comment)) |
Once again
geckodriver/webdriver itself gets already the wrong sequence. So it's not us failing here. Marking as dupe of issue #1112. |
I haven’t followed the conversation, but does this mean there is an upstream Selenium issue here? |
Yes, there is. @codingphil could you file an issue for that? |
@whimboo Are you sure it is not geckodriver issue ? I can see Chrome driver works fine with action.sendKeys(Keys.chord(Keys.CONTROL, "a")).perform(); with the same version Selenium. I think it should be a geckodriver defect. Can you confirm ? |
I am having a similar issue. It works fine when using the Chrome driver. But the same code for Gecko, I get this error: (I'm using Protractor) Adding Doing this: Both of those workarounds work fine in Chrome, but not in Firefox. |
First there is no end-point for As such your mentioned Also note that the chromedriver by default does not speak the W3C protocol, while geckodriver is doing that by default. I could believe that turning on w3c mode in chromedriver would also cause a failure. @codingphil have you had a chance to file a Selenium issue for that problem? |
List keyWithModifiers = new ArrayList(); can any one suggest me , this code make it as one or two lines. |
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue. |
Firefox Version
53.0 (64bit)
geckodriver 0.15
Platform
Windows 10 Anniversary Update (Redstone 1)
Steps to reproduce -
When sending "Ctrl-A" to
Actions.sendKeys(elem, keys)
the Ctrl key seems to be not pressed (just the 'a' character). The Ctrl-A is created viaKeys.chord()
.Sending other non-modifier special keys like Backspace works fine.
Maybe related to #233.
The following unit test fails with:
org.junit.ComparisonFailure: expected:<[]> but was:<[12345a]>
The same test works fine with Google Chrome.
The text was updated successfully, but these errors were encountered: