tsivarajan tsivarajan - 3 months ago 12
Java Question

How to calculate the page scroll length in web application?

I'm doing the below code for scroll down in selenium webdriver.

WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,250)", "");


In the above code, what is the
(0,250)
? how to calculate the
250
from the web page?

Answer

It's not really clear what you want to calculate. What is 250? lol, it could be anything, page size, window size, webelement Y location

Page Height

js.ExecuteScript("return document.body.scrollHeight");

Window Height

js.ExecuteScript("return window.innerHeight");