10

I am using FirefoxDriver webdriver. The page that loads in Firefox window is a large page and I want to scroll that page using selenium.

I want to know how this can be done.

Blaszard
  • 30,954
  • 51
  • 153
  • 233
Sandeep Kumar
  • 13,799
  • 21
  • 74
  • 110
  • I am assuming you are wanting to use the Selenium API, Here's a link to scrolling a page using the Selenium API. [Scroll Page](http://testerinyou.blogspot.com/2011/05/how-to-scroll-page.html) – Reid Mac Dec 08 '11 at 15:26
  • You should **focus** to the desired item and the selenium 2 will take care of finding it. Look at this SO post http://stackoverflow.com/questions/3401343/scroll-element-into-view-with-selenium – Aravind Yarram Dec 08 '11 at 15:26
  • driver.execute_script(f"window.scrollTo(0, {2**127});") – AturSams Jun 08 '19 at 05:34

4 Answers4

12

If you want to scroll on the firefox window using selenium webdriver, one of the way is to use javaScript in the java code, The javeScript code to scroll down is as follows:

WebDriver driver = new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," + "document.body.scrollHeight,document.documentElement.clientHeight));");
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Ankit Pandey
  • 339
  • 3
  • 4
4

I think you should do something like

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

Good Luck.

Ayyoub
  • 4,581
  • 2
  • 19
  • 32
1

Use this code to scroll single page down

Actions actions = new Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();
Undo
  • 25,519
  • 37
  • 106
  • 129
Nikesh Jauhari
  • 245
  • 2
  • 8
0
page.driver.browser.mouse.move_to( find("element").native,100,100)
kleopatra
  • 51,061
  • 28
  • 99
  • 211
vijay chouhan
  • 1,012
  • 8
  • 25