By using javaScriptExecutor we can Scroll the page of Browser to DOWN
CODE to scroll DOWN page in selenium
Example Link: https://automaticselenium.blogspot.com/p/example.html
********************CODE*******************
package aveditor;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
public class NewTest {
public static void main(String []args) throws Exception
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:\\Users\\oracle\\Music\\ChromeDriverPath\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("https://automaticselenium.blogspot.com/p/example.html");
driver.manage().window().maximize(); //Maximize the Window after Opening the Links
// Actions Class
Actions actions=new Actions(driver);
// First Click on "CheckPoint 1"
JavascriptExecutor je=(JavascriptExecutor)driver;
WebElement scroll=driver.findElement(By.xpath("//span[contains(text(),'CHECKPOINT 1========>')]"));
je.executeScript("arguments[0].scrollIntoView()", scroll);
Thread.sleep(5000); //wait for 5 sec
// Then Click on "CheckPoint2"
WebElement scroll2=driver.findElement(By.xpath("//span[contains(text(),'CHECKPOINT 2========>')]"));
je.executeScript("arguments[0].scrollIntoView()", scroll2);
Thread.sleep(5000); //wait for 5 sec
// Then Click on "CheckPoint3"
WebElement scroll3=driver.findElement(By.xpath("//span[contains(text(),'CHECKPOINT 3========>')]"));
je.executeScript("arguments[0].scrollIntoView()", scroll3);
Thread.sleep(5000); //wait for 5 sec
// Then Click on "UP TO THIS"
WebElement scroll4=driver.findElement(By.xpath("//span[contains(text(),'UP TO THIS')]"));
je.executeScript("arguments[0].scrollIntoView()", scroll4);
}
}
--------------------------------------------------------------------------------------------------------
ScrollUP: https://automaticselenium.blogspot.com/2020/01/scroll-up-in-selenium-webdriver-using.html
ScrollUP: https://automaticselenium.blogspot.com/2020/01/scroll-up-in-selenium-webdriver-using.html