You can include the below code snippet to scroll the webpage down in Selenium WebDriver
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.chrome.ChromeDriver;
public class Day1 {
WebDriver driver;
JavascriptExecutor jse;
public void invokeBrowser()
{
try {
System.setProperty("webdriver.chrome.driver", "C:\\\\Drivers\\\\chromedriver_win32\\\\chromedriver.exe");
driver= new ChromeDriver();
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.get("https://www.google.com");
searchCourse();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void searchCourse()
{
try {
driver.findElement(By.id("homeSearchBar")).sendKeys("Java");
driver.findElement(By.id("homeSearchBarIcon")).click();
jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(0,1050)");
Thread.sleep(2000);
driver.findElement(By.xpath("//label[contains(text(),'Weekend')]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//label[contains(text(),'Weekday')]")).click();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Day1 myobj = new Day1();
myobj.invokeBrowser();
}
}

