cat-ninja
cat-ninja

Reputation: 39

How to scroll in div with Selenium?

I'm trying to scroll in table on the page. I had read this answer. But it didn't works for me. This is page were table presented. How can i select it with webdriver and scroll to the bottom of it? Content in table is loadable. I need this to count how many items is in the table now. Maybe exists some other hint to make it easier?

Upvotes: 0

Views: 2014

Answers (1)

Moshisho
Moshisho

Reputation: 2981

You can scroll using JavaScript:

JavascriptExecutor jsExec = (JavascriptExecutor) driver;
jsExec.executeScript("document.querySelector('#gwt-debug-contentPanel > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(1) > div.GNHGC04CJJ').scrollTop = 500");

But to find out the number there's an easier way:

WebElement number = driver.findElement(By.cssSelector("#gwt-debug-contentPanel > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(1) > div.gwt-HTML"));
String range = number.getText();

Then parse the higher number to an integer.

Upvotes: 1

Related Questions