Created
January 30, 2024 10:17
-
-
Save SarahElson/4597cc0d6ab2844d26a9c31221f4d281 to your computer and use it in GitHub Desktop.
How To Scroll Down in Selenium WebDriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.testng.annotations.Test; | |
public class ScrollDownByElementVisibility extends BaseTest{ | |
@Test | |
public void testScrollDownByElementVisibility() | |
{ | |
//launch the website | |
driver.get("https://www.lambdatest.com/selenium-playground/"); | |
//specify the WebElement till which the page has to be scrolled | |
WebElement element = driver.findElement(By.linkText("Espresso Testing")); | |
//get the height of the web page and scroll to the end | |
js.executeScript("arguments[0].scrollIntoView();", element); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment