Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I scroll down using selenium

The code is as below.

driver = webdriver.Chrome(chromedriver_path) #webdriver path

driver.get('https://webtoon.kakao.com/content/%EB%B0%94%EB%8B%88%EC%99%80-%EC%98%A4%EB%B9%A0%EB%93%A4/1781') #website access
time.sleep(2)

driver.execute_script("window.scrollTo(0, 900)") #scroll down
time.sleep(1)

However, the page does not scroll.

How can I scroll?

Page link to be scrolled

like image 749
Noob Master 69 Avatar asked Oct 19 '25 09:10

Noob Master 69


2 Answers

Try this

driver.execute_script("window.scrollTo(100,document.body.scrollHeight);")
like image 51
httpanand Avatar answered Oct 21 '25 23:10

httpanand


Tried with the below code, it did scroll.

driver.get("https://webtoon.kakao.com/content/%EB%B0%94%EB%8B%88%EC%99%80-%EC%98%A4%EB%B9%A0%EB%93%A4/1781")
time.sleep(2)
options = driver.find_element_by_xpath("//div[@id='root']/main/div/div/div/div[1]/div[3]/div/div/div[1]/div/div[2]/div/div[1]/div/div/div/div")
driver.execute_script("arguments[0].scrollIntoView(true);",options)
like image 32
pmadhu Avatar answered Oct 22 '25 01:10

pmadhu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!