4

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

3 Answers 3

5

Try this

driver.execute_script("window.scrollTo(100,document.body.scrollHeight);") 
Sign up to request clarification or add additional context in comments.

5 Comments

The following error message is output - AttributeError: 'WebDriver' object has no attribute 'executeScript'
oh .. could you please check this ? driver.execute_script("window.scrollTo(900, Y)")
It doesn't scroll and it doesn't change anything.
driver.execute_script("window.scrollTo(100,document.body.scrollHeight);") This works for me !!
It doesn't work. Can I see the full code?
3

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) 

Comments

1

The webapp is dynamic (which is, the more you scroll down, more you will see the data), you can perform infinite scrolling like below :-

driver = webdriver.Chrome(chromedriver_path) #webdriver path driver.maximize_window() driver.implicitly_wait(30) 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) wait = WebDriverWait(driver, 20) time.sleep(5) action = ActionChains(driver) i = 3 while True : action.move_to_element(driver.find_element(By.XPATH, f"(//div[contains(@class, 'AspectRatioBox_aspectRatioBox')])[{i}]")).perform() i = i +1 time.sleep(.5) 

Imports :

from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains 

2 Comments

What is the f reference in (By.XPATH, f"(//... ?
@Hammertime: to pass the dynamic value

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.