How to scroll elements into view by running Selenium tests with JUnit on LambdaTest cloud?

How to scroll elements into view by running Selenium tests with JUnit on LambdaTest cloud?

Hi Ian,

It is simple to scroll elements into view by running Selenium JUnit tests on LambdaTest cloud. You can add the below code snippet to your automation scripts.

  // Locating element by link text 
        WebElement Element = driver.findElement(By.linkText("Book a Demo"));
        // Scrolling down the page till the element is found
        driver.executeScript("arguments[0].scrollIntoView();", Element);
        Thread.sleep(1500);
        // Scrolling down by pixels
        driver.executeScript("window.scrollBy(0,-500)", "");
        Thread.sleep(1500);
        // Scrolling up by pixels
        driver.executeScript("window.scrollBy(0,500)", "");

You can download and install the given GitHub repo.