How to scroll an element into view in Selenium

Published: 16 March 2021
on channel: automateNow
3,178
29

Learn how to scroll an element into view (visible area of the browser window) in Selenium WebDriver.

** UPDATE **
Selenium 4 offers an easier way to scroll a web page without the use of JavascriptExecutor!
https://www.selenium.dev/documentatio...

Although Selenium WebDriver does not have a method that we can use to scroll a given element into view, we can use its JavascriptExecutor interface along with the HTML DOM's scrollIntoView method to execute some JavaScript code that will do just that. This video will show you how it is done.

Can you think of some reasons why we may want to scroll an element into view when using Selenium WebDriver? Please leave your comments below!

You can find the source code for this project on automateNow's GitHub page.
https://github.com/automatenow/IntroT...

😀 Subscribe for weekly videos! 👍

📑 CHAPTERS

0:00 ~ Intro
0:15 ~ Scenario description
0:37 ~ Writing the test
1:53 ~ Using JavascriptExecutor interface
4:17 ~ Running the test
4:44 ~ Setting the scrolling alignment

👩‍🎓 COURSES

☕ Java For Absolute Beginners https://bit.ly/learn-java2022

⏯ PLAYLISTS

☑️ Automation Fundamentals https://bit.ly/2QbN7qm
☑️ Automation Tools https://bit.ly/2OFj4qO
☑️ General WebDriver https://bit.ly/2Z3tG7y
☑️ Intro to WebDriver https://bit.ly/3gb5Jlx
☑️ Intermediate WebDriver https://bit.ly/2OBTR0r
☑️ Java https://bit.ly/3sBuI7M
☑️ Selenium 4 https://bit.ly/2VQ1lA9
☑️ Version Control https://bit.ly/3CvHplU
☑️ Web Element Locators https://bit.ly/2QfDGpK

📫 LET'S CONNECT!

☑️ https://linktr.ee/automateNow

🔗 REFERENCES

☑️ W3Schools https://bit.ly/3s66bUr
☑️ W3Schools https://bit.ly/321RdUK


Watch video How to scroll an element into view in Selenium online without registration, duration hours minute second in high quality. This video was added by user automateNow 16 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3,178 once and liked it 29 people.