Skip to content Skip to sidebar Skip to footer

Scroll A Specific Part Of A Website With Selenium.

I'm trying to create a script that will be used to scroll this site: http://m.1688.com/offer/39202959720.html?spm=a26g8.7664812.0.0.dfxn8I As you can see on the site if the cursor

Solution 1:

Try to use below code to scroll content down:

from selenium.webdriver.common.keys import Keys

driver.get('http://m.1688.com/offer/39202959720.html?spm=a26g8.7664812.0.0.dfxn8I')

# Click on element inside the main content to switch focus
driver.find_element_by_xpath('//h1[@class="d-title"]').click()

for i in range(5):
    # Scroll page down
    driver.find_element_by_tag_name('body').send_keys(Keys.END)
    time.sleep(2)

Post a Comment for "Scroll A Specific Part Of A Website With Selenium."