Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created January 30, 2024 16:25
How To Scroll Down in Selenium WebDriver
package test;
import org.openqa.selenium.*;
import org.testng.annotations.Test;
public class ScrollToSpecificElement extends BaseTest
{
@Test
public void testScrollToSpecificElement()
{
//launch the website
driver.get("https://www.lambdatest.com/selenium-playground");
//locate the element
WebElement element = driver.findElement(By.linkText("Changelog"));
//scroll to the element
js.executeScript("arguments[0].scrollIntoView();", element);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment