Sunday, 26 July 2015

Scroll down the Window using Actions.

Use java script to scroll down-




JavascriptExecutor jsx = (JavascriptExecutor)driver;

 jsx.executeScript("window.scrollBy(0,4500)", ""); //scroll down, value 4500 you can change as per your req

 jsx.executeScript("window.scrollBy(450,0)", ""); //scroll up

 ex-

 public class ScrollDown {

 public static void main(String[] args) throws InterruptedException {

 WebDriver driver = new FirefoxDriver();

 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

 driver.get("http://www.flipkart.com/womens-clothing/pr?sid=2oq,c1r&otracker=hp_nmenu_sub_women_1_View%20all");

 driver.manage().window().maximize();

 JavascriptExecutor jsx = (JavascriptExecutor)driver;

 jsx.executeScript("window.scrollBy(0,4500)", ""); //scroll down

 Thread.sleep(3000);

 jsx.executeScript("window.scrollBy(450,0)", ""); //scroll up

 }

 }

No comments:

Post a Comment