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

Clicking a partially hidden button is not handled correctly in Firefox (Java WebDriver 2.53.0) #2521

Closed
Marrowbones opened this issue Jul 26, 2016 · 3 comments

Comments

@Marrowbones
Copy link

Marrowbones commented Jul 26, 2016

OS: Windows 7 (and others)
Selenium Version: 2.53.0 (possibly others after 2.47)
Java version: 1.8.0_101 (also tried various others including 1.7.0_65)
Browser: Firefox (multiple versions between 34.0.5 and 44.0.1)

Expected Behavior -

If a button is partially hidden, trying to click it should do one of the following:

  1. Throw an exception ("Element is not clickable ... Other element would receive the click")
  2. Click correctly, presumably if the centre of the button is clickable.

Actual Behavior -

In certain cases, WebDriver thinks it has correctly clicked the button (no exception is thrown), but the button is not clicked. Works fine in Chrome. I believe this is a reproducable version of #1202

Steps to reproduce -

Run the following code (images attached for reference)

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class SeleniumTest {

    static WebDriver driver;
    static WebDriverWait wait;
    static String url = "https://home.bt.com/login/loginform"; // any old URL that illustrates this well
    static String xp  = "//input[@value=\"Log in\"]";
    static String txt = "";

    public static void main(String[] args) {
        System.out.println("Running under: " + System.getProperty("java.version"));
        // setup
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        driver = new FirefoxDriver(capabilities);
        wait = new WebDriverWait(driver, 30);
        // do it (replicates issue on a screen resolution of 1920x1080)
        tryIt(1400, 800); // button in view   - OK... button clicked successfully, so page sends required fields red
        tryIt(1150, 650); // totally hidden   - OK... expected exception of 'Element is not clickable ... Other element would receive the click'
        tryIt(1350, 650); // partially hidden - BUG?? webdriver thinks it clicked it, but nothing happens (fields don't go red)
        driver.quit();
    }

    private static void tryIt(int x, int y) {
        try {
            System.out.println("Trying " + x + ", " + y);
            driver.manage().window().setSize(new Dimension(x,y));
            driver.get(url);
            WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xp)));
            System.out.println("    Element is: " + el.toString() + " ... " + el.getLocation());
            el.click();
            System.out.println("    CLICKED OK");
        } 
        catch (Exception e) {
            System.out.println("    Caught exception (probably not clickable) "); // + e.getLocalizedMessage());
        }
        System.out.println("Done");
        try {Thread.sleep(2000);} catch (InterruptedException e) {}
    }

}

Image 1
// button in view - OK... button clicked successfully, so page sends required fields red

sel-1

Image 2
// totally hidden - OK... expected exception of 'Element is not clickable ... Other element would receive the click'

sel-2

Image 3
// partially hidden - BUG?? webdriver thinks it clicked it, but nothing happens (fields don't go red)

sel-3

@lukeis
Copy link
Member

lukeis commented Jul 26, 2016

this was actually fixed very recently and is a duplicate of #2497
23a24f5

The problem was we were attempting to click on the corner, but the corner is rounded and thus the click doesn't actually hit the button! Code was changed to check the middle of the borders first, then the corners if no side is found.

@lukeis lukeis closed this as completed Jul 26, 2016
@Marrowbones Marrowbones changed the title Clicking a partially hidden button is not handled correctly (Java WebDriver 2.53.0) Clicking a partially hidden button is not handled correctly in Firefox (Java WebDriver 2.53.0) Jul 26, 2016
@Marrowbones
Copy link
Author

Thanks - obviously my searching isn't as good as I thought.

Will there be a minor (bug fix) release of 2.53 at any point? I know you're all working on 3.0, but I think a lot of people would appreciate a pacthed version of the latest v2 stuff, as I'm guessing many people won't be able to immediately move to v3.

Thanks again.

@lukeis
Copy link
Member

lukeis commented Jul 26, 2016

3.0 is coming soon... and there should be no reason to not move immediately to it. The only major difference is marionette:true is default, you'll need to set it to false (desired capability) to use the 'old' firefox driver.

If you have concerns about moving the 3.0 feel free to bring them up? Or try out the latest build from CI -
http://ci.seleniumhq.org:8080/job/Build_All_Java/lastSuccessfulBuild/artifact/selenium-server-standalone-latest.jar

If you use maven there's instructions on the README of the repo on how to do a mvn install of the selenium project to test out 3.0-beta1

@lock lock bot locked and limited conversation to collaborators Aug 19, 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