#selenium #webDriver #scrollBar # JavascriptExecutor
JavascriptExecutor is a class and we have to cast out driver into JavascriptExecutor. Once it's done. We can use reference variable to use executeScript () method. And this method is used to execute Javascript code. Since Scroll bar is a Javascript function, so JavascriptExecutor class is the best option to automate in Selenium.
Example:
// Scroll down of a page :
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("scroll(0, 500);");
// Scroll up of a page :
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("scroll(0, -500);");
// Scroll page all the way down:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("scrollTo(0,document.body.scrollHeight )");
------------------------------------------------------------------------
Follow Us on Social Media:
------------------------------------------------------------------------
FaceBook: / codenboxqa
Twitter: / codenboxteam
LinkedIn: / codenbox-. .
YouTube for Selenium Practice: // • Locators-Part 1: How to spy elements ...
YouTube for Agile Practice: https://www.youtube.com/playlist?list...
Blog: http://codenboxautomationlab.com/