Menu Close

How to scroll a web page using Selenium webdriver in Python?

Sometimes, we want to scroll a web page using Selenium webdriver in Python.

In this article, we’ll look at how to scroll a web page using Selenium webdriver in Python.

How to scroll a web page using Selenium webdriver in Python?

To scroll a web page using Selenium webdriver in Python, we can run the JavaScript window.scrollTo method.

For instance, we write

driver.execute_script("window.scrollTo(0, y)") 

to call window.scrollTo on the opened page to scroll to vertical position y.

Conclusion

To scroll a web page using Selenium webdriver in Python, we can run the JavaScript window.scrollTo method.

Posted in Python, Python Answers