scroll down in selenium

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class ScrollByPixel {

    WebDriver driver;
    @Test
    public void ByPixel() {
        System.setProperty("webdriver.chrome.driver", "E://Selenium//Selenium_Jars//chromedriver.exe");
        driver = new ChromeDriver();

        JavascriptExecutor js = (JavascriptExecutor) driver;

        // Launch the application		
        driver.get("http://demo.guru99.com/test/guru99home/");

        //To maximize the window. This code may not work with Selenium 3 jars. If script fails you can remove the line below		
        driver.manage().window().maximize();

        // This  will scroll down the page by  1000 pixel vertical		
        js.executeScript("window.scrollBy(0,1000)");
    }
}

0
1

                                     Selenium does not have a method for scrolling
 but there are some ways to scroll:
 
   #1 ->=moveToElement= coming from Actions class
   will scroll down and up to given web element
   #2 Using JSExecutor: We can inject JavaScript
   code in our Java+Selenium code using JSExecutor
   which helps us scroll up, down, left, right.
   We need to create instance of JS executor,
   then cast our driver type of it.
==================================================   
   
  syntax is =   
   JavaScriptExecutor js = (JavaScriptExecutor) Driver.getDriver();
   js.executeScript("in here we need to pass js code that scrolls");
    
  
     js.executeScript("window.scrollBy(0,250)");
     js.executeScript("arguments[0].scrollIntoView(true);", WebElement);

0
0
5
1
ShadowCat7 70 points

                                    Selenium does not have a method for scrolling
but there are some ways to scroll:
#1 ->=moveToElement= coming from Actions class
   will scroll down and up to given web element
#2 Using JSExecutor: We can inject JavaScript
   code in our Java+Selenium code using JSExecutor
   which helps us scroll up, down, left, right.
   We need to create instance of JS executor,
   then cast our driver type of it.
WebDriver driver = new ChromeDriver(); 
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(0, 250);"); Scroll Down
jse.executeScript("scroll(0,-250);"); Scroll Up

5 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
scroll down selenium how to scroll down specific element in selenium webdriver selenium scroll down select selenium java scroll down selenium simulate scroll down scroll down using java executer selenium selenium script Scrolldown code java slowly scroll down javascript selenium scroll down in selenium using action class how to scroll down selenium scroll horizontal in selenium how to scroll to an element in selenium scroll down seleinium scroll in javascript selenium handle selenium scrolling java handle selenium scroll java selenium scroll down page scroll to the end selenium window scroll selenium selenium scroll down java selenium script to scroll down the page selenium page scroll scroll page in selenium How to scroll on selenuim scroll down to page in selenium selenium scroll down to the end SELENIUM SCROLL DOWN WEB PAGE java script scroll in selenium how to scroll particular section in selenium webdriver scroll down in javascript selenium scroll on page selenium how to scroll window in selenium window scroll in selenium selenium select scroll scroll up and scroll down in selenium how to scroll down in selenium java selenium scroll element selenium library scroll how to scroll the page in selenium java javascript for scroll down selenium how to handle scrollbar in selenium how to scroll page in selenium scroll method in selenium can selenium scroll scroll in selenium java selenium set scroll level scoll in selenium selenium hacer scroll java selenium hacer scroll scroll in element selenium scroll in selenium selenium ide scroll how to scroll in selenium webdriver selenium obscures it scroll selenium mouse scroll down java scroll down embedded selenium scroll down in selenium c# scroll and select in selenium how to scroll the web page in selenium scroll to view selenium in java scroll to view in selenium how do scroll selenium selenium scroll down in java scroll by method in selenium scroll through followers selenium java scroll down webelement selenium scroll down selenium java how to click on scroll bar in selenium selenium scroll bar page scroll in selenium c# selenium scroll scrolling down in selenium scroll into view selenium java scroll down windows selenium how to handle scroll down in selenium scrolling with selenium scrolling page in selenium scroll using selenium c# scroll up selenium scroll using selenium selenium, scroll scroll by selenium how to scroll in selenium java how to scroll a webpage using selenium scroll browser in selenium how to scroll down the webpage in selenium how to scroll down with selenium scroll selenium' Selenium scrolling selenium scroll up how to scroll down in selenium using java scroll down webdriver scroll from up to down in selenium how to scroll with selenium java scroll to bottom javascript selenium chromedriver scroll chromedriver scroll down code to scroll down in selenium do i need to scroll in selenium javascript executor scroll put selenium page down how to scrolll with selenium window scroll up selenium how to use scroll down in selenium "scroll down the page" script to scroll up down how to scroll middle bar in app in selenium selenium scrolltop how to scroll selenium java selenium scroll page jmeter selenium popup scroll down to bottom scroll down using selenium java scroll down full xpath selenium move down javascriptexecutor scroll scrollto javascriptexecutor scroll up javascript selenium scroll up selenium java mongodb "SCROLL TO THE BOTTOM OF THE PAGE TO LOCATE THE IN-BROWSER IDE" "SCROLL TO THE BOTTOM OF THE PAGE TO LOCATE THE IN-BROWSER IDE" scrolldown selenium selenium executeScript scroll how to scroll with selenium webdrive with javascript scrollup using selenium how to scroll down using javascript in selenium webdriver selenium auto scroll javascript code for scroll down up to end of in web page scroll vetically within an element javascript selenium how to scroll down in selenium webdriver java how to scroll down and up in selenium selenium .scroll javascript for scroll down in selenium webdriver how to scroll down page in selenium c# how to make scroll down in selenium arguments[0].scrollTop means how to scroll down a div in chrome using selenium scroll up in selenium how to scroll browser window in selenium using javascript is it safe to scroll with javascript selenium selenium schroll how to scroll with selenium python how to scroll with selenium scroll a div in selenium scroll to element selenium page scrooler test up selenium scroll till javascript executor for scrolling page scrol up code scroll windown down in selenium selenium scroll to top of page selenium scroll to top javascript to scroll down in selenium scroll down on page selenium sroll page selenium driver.scroll scroll page selenium page scroll down in selenium scroll down selenium scroll selenium selenium scroll javascript selenium driver scroll to scroll javascript selenium scrollto in selenium how to scroll down using selenium scroll to bottom of page selenium how to scroll in selenium js ExecuteScript to scroll down scroll with selenium scroll to bottom in selenium scrollup javascriptexecutor selenium selenium how to scroll down how to scroll up in selenium scrolling selenium selenium java scroll selenium web driver scroll down scrolling in selenium selenium. scroll down scroll javascriptExcutor by pixels scroll in java selenium how to use scrollup in javascript how to scroll to bottom in selenium how to scroll down with webdriver scroll to y axis selenium ruby scroll to y axis selenium seleniiukm browser scroll scroll_to selenium scrollto selenium how to scroll a page in selenium selenium scroll down how to scroll down in selenium how to scroll down form page in selenium how to scroll down page in selenium selenium scroll openqa selenium scroll point element at the left top of the page open qa selenium scroll point element at the left top of the page scroll down in selenium java scroll down in selenium
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source