Skip to content
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

sendKeys(" ") does not check checkbox #777

Closed
1 task
codingphil opened this issue Jun 8, 2017 · 4 comments
Closed
1 task

sendKeys(" ") does not check checkbox #777

codingphil opened this issue Jun 8, 2017 · 4 comments

Comments

@codingphil
Copy link

Platform and application details

Windows 10 Creators Update
Firefox: 54.0 (beta)
Selenium: 3.4 (Java)

Steps to reproduce

Run the following Java Selenium test.

  public void testSendKeysSpaceToCheckbox()  {
    webDriver.navigate().to("https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/input/checkbox$samples/Basic_example");
    
    WebElement checkbox = webDriver.findElementById("checkBox");
    assertEquals("input", checkbox.getTagName());
    assertEquals("checkbox", checkbox.getAttribute("type"));
    
    assertFalse("checkbox is NOT selected before pressing SPACE", checkbox.isSelected());
    
    checkbox.sendKeys(" ");
    
    assertTrue("checkbox is selected after pressing SPACE", checkbox.isSelected());
  }

It will fail with java.lang.AssertionError: checkbox is selected after pressing SPACE

A simple test page with a checkbox with the id "checkBox" is used:
https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/input/checkbox$samples/Basic_example

@andreastt
Copy link
Contributor

It’s not supposed to be possible to select a checkbox using the high-level WebElement.sendKeys API. You need to use the low-level actions API for that.

@codingphil
Copy link
Author

This is not very intuitive. Both variants of sendKeys() methods should have the same functionality.
At least for the Java programmer it is not very understandable.

Have you any reference to a standard/spec where it is defined that this should not work?
At least in Chrome this works fine.

@andreastt
Copy link
Contributor

andreastt commented Jun 8, 2017 via email

@lock
Copy link

lock bot commented Aug 17, 2019

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.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants