Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我能';我无法使用python在Selenium中向下滚动_Python_Selenium_Scroll_Webdriver - Fatal编程技术网

我能';我无法使用python在Selenium中向下滚动

我能';我无法使用python在Selenium中向下滚动,python,selenium,scroll,webdriver,Python,Selenium,Scroll,Webdriver,我试图向下滚动页面,因为在我单击按钮一次后,帮助元素与下一页按钮重叠,因为页面向下移动。 “下一步”按钮位于“匹配历史记录”表上方。 我试着用 driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") element=driver.find_element_by_xpath("//table[@class='Table flx-sm dir-r-sm jst-s-sm flx-

我试图向下滚动页面,因为在我单击按钮一次后,帮助元素与下一页按钮重叠,因为页面向下移动。 “下一步”按钮位于“匹配历史记录”表上方。 我试着用

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
element=driver.find_element_by_xpath("//table[@class='Table flx-sm dir-r-sm jst-s-sm flx-nw-sm ialgn-st-sm']")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
html = driver.find_element_by_tag_name('html')
html.send_keys(Keys.END)
什么都没有发生, 然后我试着用

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
element=driver.find_element_by_xpath("//table[@class='Table flx-sm dir-r-sm jst-s-sm flx-nw-sm ialgn-st-sm']")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
html = driver.find_element_by_tag_name('html')
html.send_keys(Keys.END)
它给出了一个错误:
MoveTargetOutOfBoundsException:消息:(1009835)超出了视口宽度(1536)和高度(750)

我试着用

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
element=driver.find_element_by_xpath("//table[@class='Table flx-sm dir-r-sm jst-s-sm flx-nw-sm ialgn-st-sm']")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
html = driver.find_element_by_tag_name('html')
html.send_keys(Keys.END)
没有任何东西在移动。这是我正在尝试的代码和网站。(我也尝试过使用Chrome,但我得到了相同的结果)

您必须找到滚动元素,然后在该元素上使用scrolBY

driver.execute_script("$('[class=\"el-main\"]').scrollBy(0,$('[class=\"el-main\"]').scrollHeight);")
如果您获得$notdefined,请使用:

driver.execute_script("arguments[0].scrollBy(0,arguments[0].scrollHeight);", driver.find_element_by_class_name('el-main'))
您也可以这样做:

driver.get(url2)

driver.find_element_by_class_name('el-main').click()

driver.find_element_by_css_selector("body").send_keys(Keys.END)
首先,你们必须通过点击滚动来聚焦它,然后在主体上发送结束键

查找定位器:

driver.get(url2)

driver.find_element_by_class_name('el-main').click()

driver.find_element_by_css_selector("body").send_keys(Keys.END)