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

Actions.click(WebElement) is not triggered #584

Closed
asashour opened this issue Mar 29, 2017 · 7 comments
Closed

Actions.click(WebElement) is not triggered #584

asashour opened this issue Mar 29, 2017 · 7 comments

Comments

@asashour
Copy link

Firefox Version

ESR 52.0.1 (64-bit)

geckodriver version

v0.15.0

Platform

Windows

Steps to reproduce -

<html><body>
<select id='s' multiple>
  <option selected value='one'>One</option>
  <option value='two'>Two</option>
  <option selected value='three'>Three</option>
</select>
</body></html>
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();

    FirefoxOptions ffOptions = new FirefoxOptions();
    ffOptions.setLogLevel(Level.ALL);
    capabilities.setCapability("moz:firefoxOptions", ffOptions);

    final WebDriver driver = new FirefoxDriver(capabilities);

    try {
        driver.get("http://localhost:8080/");
        final WebElement multiSelect = driver.findElement(By.id("s"));
        final List<WebElement> options = multiSelect.findElements(By.tagName("option"));

        // options.get(0).click();
        new Actions(driver).click(options.get(0)).perform();

        System.out.println(options.get(0).isSelected());
        System.out.println(options.get(1).isSelected());
        System.out.println(options.get(2).isSelected());
    }
    finally {
        driver.quit();
    }

Expected (as IE/Chrome):

true
false
false

Actual:

true
false
true

It seems geckodriver doesn't trigger the click action on <option> elements.

Here is the log file

@andreastt
Copy link
Contributor

You can’t use the actions API to interact with <option> elements since they are not interactable/displayed. IE/Chrome is wrong here.

@andreastt
Copy link
Contributor

To be clear, the actions API is meant as a low-level “do as I tell you to” interface to gain direct control of the mouse pointer. The Element Click command is high-level and will perform extra magic to let you select a (non-interactable) <option> element inside <select>. This is supported by geckodriver and Marionette.

@asashour
Copy link
Author

Just a hint, I see with geckodriver 0.16, selenium-firefox-driver 3.4.0 and Firefox 52.1.0 ESR, this seems to be changed.

And the actual values now match with ChromeDriver:

true
false
false

However, InternetExplorerDriver 3.4.0 was changed to print:

true
false
true

@andreastt
Copy link
Contributor

Is there a particular reason why you can’t click an element directly? options.get(0).click() is the way WebDriver recommends selecting an option.

@asashour
Copy link
Author

Actually, my focus is to know how web driver should exactly behave, in order to implement it in HtmlUnitDriver, and I am using Firefox/Chrome/IE as reference implementations.

@andreastt
Copy link
Contributor

Most drivers are converging around the W3C WebDriver standard, which explains exactly how a driver should behave. Unfortunately Selenium itself is not entirely compliant yet, but it is getting there.

@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