How To Scroll Web Page Down Or UP Using Selenium WebDriver?
Question
How To Scroll Web Page Down Or UP Using Selenium WebDriver?
Answer
JavaScript scrollBy() method scrolls the document by the specified number of pixels.
Syntax for scrollBy() is
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(""window.scrollBy(x-pixels,y-pixels)"");
Example:
js.executeScript(""window.scrollBy(0,1000)""); //Scroll vertically down by 1000 pixels
š² Practice Offline on Mobile: Download the free QA Automation & SDET Prep app on Google Play & App Store.