使用Selenium Python chromeDriver向下滚动到结束页面

时间:2018-08-11 10:59:47

标签: python selenium-chromedriver

请帮助,我想向下滚动到Bage的尽头,但它停止了。 我尝试的代码在这里

browser = webdriver.Chrome()
browser.get(url)
button = browser.find_element_by_tag_name("html")
old=""
new=" "

while len(new)>len(old):
    old = browser.page_source
    button.send_keys(Keys.END)
    browser.implicitly_wait(40)
    new = browser.page_source

1 个答案:

答案 0 :(得分:0)

您的脚本

fun foo(clazz: Class<*>) {
  // 1. How to know clazz is collection?
  // 2. How to know T of Collection<T> is String?
}

fun myFunc() {
  val mySet: HashSet<String> = HashSet()
  foo(mySet::class.java)
}

您可以设置否。全长需要滚动的纸卷

driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")