Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
A Scrollbar is helped you to circulate round display in vertical route if the modern-day web page scroll does now no longer the seen place of the display. It is used to transport the window up and down. Selenium Webdriver does now no longer requires scroll to carry out moves because it manipulates DOM. But in positive internet pages, factors best emerge as seen as soon as the person has scrolled to them. In such instances, scrolling can be necessary.
Requirements:
selenium
You need to install chromedriver and set the path. Click here to download.
Step-by-step Approach:
Step 1: Import required modules
Python3
from selenium import webdriver
import time
from webdriver_manager.chrome import ChromeDriverManager
driver=webdriver.Chrome(ChromeDriverManager().install())
Step 2: Taking any URL .
Python3
from selenium import webdriver
import time
from webdriver_manager.chrome import ChromeDriverManager
driver=webdriver.Chrome(ChromeDriverManager().install())
Step 3: Maximize the window.
Step 4: Scrolling base on the pixel.
Python3
driver.execute_script("window.scrollBy(0,2000)","")
Below is the full Implementation:
Python3
from selenium import webdriver
import time
from webdriver_manager.chrome import ChromeDriverManager
driver=webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.execute_script("window.scrollBy(0,2000)","")
time.sleep(4)
Output:
Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.
Last Updated :
28 Apr, 2022
Like Article
Save Article
Share your thoughts in the comments
Add Your Comment
Please Login to comment...