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.

4
  • You should focus to the desired item and the selenium 2 will take care of finding it. Look at this SO post stackoverflow.com/questions/3401343/… Commented Dec 8, 2011 at 15:26
  • 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 Commented Dec 8, 2011 at 15:26
  • driver.execute_script(f"window.scrollTo(0, {2**127});") Commented Jun 8, 2019 at 5:34
  • This question is similar to: How can I scroll a web page using selenium webdriver in python?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 15, 2024 at 23:53

4 Answers 4

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));");
Sign up to request clarification or add additional context in comments.

Comments

4

I think you should do something like

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

Good Luck.

Comments

1

Use this code to scroll single page down

Actions actions = new Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();

3 Comments

Are you sure it's the correct key to send? It seems it would the a backspace key press, which would not scroll the page.
Page Down key perhaps?
Oh dear #facepalm
0
page.driver.browser.mouse.move_to( find("element").native,100,100)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.