In a web page the scroll down of the page should be done automatically.The example is given below.
package TestNG;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
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%2Cc1r...");
driver.manage().window().maximize();
JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,4500)", "");
Thread.sleep(3000);
driver.close();
}
}
To know FAQ's on Selenium Please ClickHere
To know SQL's Queries Required For Testers Please ClickHere
package TestNG;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
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%2Cc1r...");
driver.manage().window().maximize();
JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,4500)", "");
Thread.sleep(3000);
driver.close();
}
}
To know FAQ's on Selenium Please ClickHere
To know SQL's Queries Required For Testers Please ClickHere
No comments:
Post a Comment