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

((Locatable) element).getCoordinates().inViewPort() doesn't scroll to element in selenium-java #1527

Closed
QALady opened this issue Jan 25, 2016 · 6 comments

Comments

@QALady
Copy link

QALady commented Jan 25, 2016

((Locatable) element).getCoordinates().inViewPort() doesn't scroll to element.

Steps to reproduce:

  1. Deploy the SmartGwtTester-1.0.war to e.g. Tomcat (pls see comment about attachment below)
  2. Execute the following test:
public class ScrollingIssue {

    private static Logger LOG = LoggerFactory.getLogger(ScrollingIssue.class);
    private static Logger BROWSER_LOG = LoggerFactory.getLogger("Browser");

    WebDriver driver = new FirefoxDriver();
    WebDriverWait wait = new WebDriverWait(driver, 5);

    @Test
    public void simpleTest() {
        //open  URL
        driver.get("http://localhost:8888/SmartGwtTester-1.0/");
        driver.manage().window().maximize();
        List<WebElement> results = driver.findElements(By.xpath("//td[@class='treeCell']//tbody/tr"));
        int items = results.size();
        System.out.println("total number of items is " + items);
        int i = 0;
        for (WebElement result : results) {
            ((Locatable) result).getCoordinates().inViewPort();
            WebElement itemLabel = result.findElement(By.xpath("./td[3][@class='treeCell'][contains(@style, 'white-space:nowrap')]"));
            String itemLabelText = itemLabel.getText();
            System.out.println("Click on #" + (i + 1) + " " + itemLabelText);
            WebElement checkbox = result.findElement(By.xpath("./td[2][@class='treeCell']/span[2]"));
            checkbox.click();
            i++;
        }
    }
}

Actual Result: The inViewPort() is not scrolling to 15th element in to view so the test is failing starting this point. All elements before #15 were already in View by default.

The issue is reproducible starting from Selenium 2.35 till Selenium 2.49.1 inclusive. The last working version is 2.34.

I have the war file to reproduce this issue unfortunately the file size is more than 10MB allowed. Please let me know where I can upload it.
Update: The file can be downloaded from here: http://turbobit.net/ih19hhutyehx.html

@QALady QALady changed the title ((Locatable) element).getCoordinates().inViewPort() doesn't scroll to element ((Locatable) element).getCoordinates().inViewPort() doesn't scroll to element in selenium-java Jan 25, 2016
@barancev
Copy link
Member

You can use a file hosting (Dropbox, Google Drive etc) to upload large files.

@QALady
Copy link
Author

QALady commented Jan 25, 2016

I have uploaded the war file here: http://turbobit.net/ih19hhutyehx.html

@barancev
Copy link
Member

Yes, Selenium does not support custom scrollbars. One have to click to a scrollbar element explicitly to perform scrolling.

@QALady
Copy link
Author

QALady commented Jan 31, 2016

As far as I understand Selenium inViewPort() method does not use any custom or not custom scroller to make element visible. instead javascript is involved. also Selenium Webdriver versions before 2.35 did not have this issue. (checked with the same test page). So this defect was introduced starting Selenium 2.35

@barancev
Copy link
Member

barancev commented Feb 1, 2016

OK, if it's scrollable by JS then it must be a bug.

@barancev
Copy link
Member

barancev commented Feb 1, 2016

Fixed by commit 2f59645

@barancev barancev closed this as completed Feb 1, 2016
@lock lock bot locked and limited conversation to collaborators Aug 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants