如果您对PythonSelenium.execute_script("window.scrollTo(0,document.body.scrollHeight);")不向下滚动感兴趣,那么本文将是一篇
如果您对Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动的详细内容,并且为您提供关于$(window).scrollTop() 与 $(document).scrollTop()、$(window).scrollTop()和$(document).scrollTop()区别、(document).height()、$(document).scrollTop()、(document).height()和$(window).height()、scrollTop的有价值信息。
本文目录一览:- Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动
- $(window).scrollTop() 与 $(document).scrollTop()
- $(window).scrollTop()和$(document).scrollTop()区别
- (document).height()、$(document).scrollTop()
- (document).height()和$(window).height()、scrollTop
Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动
如何解决Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动?
我正在尝试打开此页面 https://justjoin.it/warszawa/devops,然后滚动到页面底部。 我已经尝试过这种方式,但不幸的是它不起作用。
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import webdriverwait
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get(
"https://justjoin.it/warszawa/devops")
close_popup = webdriverwait(driver,10).until(
EC.element_to_be_clickable((By.XPATH,''//*[@id="root"]/div[1]/button''))).click()
time.sleep(3)
print(''Time over!'')
driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
解决方法
试试 ActionChains
是否适合您。下面分享一个例子。根据您的要求使用它。
from selenium.webdriver import ActionChains
last_element=driver.find_element_by_xpath("{{xpath of last element in the page}}")
a = ActionChains(driver)
a.move_to_element(last_element).perform()
$(window).scrollTop() 与 $(document).scrollTop()
有什么区别:
$(window).scrollTop()
和
$(document).scrollTop()
谢谢。
答案1
小编典典它们都将产生 相同的效果 。
但是,正如评论中所指出的: $(window).scrollTop()
支持的网络浏览器多于$(''html'').scrollTop()
.
$(window).scrollTop()和$(document).scrollTop()区别
【前言】
$(document).scrollTop()与 $(window).scrollTop()都是针对浏览器滚动条,两者效果完全相同。但是也有区别,这里记录下
【主体】
针对浏览器窗口的滚动条,两者在ie下有兼容性,
jQuery中,$(document).scrollTop()与 $(window).scrollTop()效果完全相同
但是,$(window).scrollTop()被所有浏览器支持所以,以后尽量用$(window).scrollTop()
(document).height()、$(document).scrollTop()
<table><tbody><tr>
<td><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
总结
以上是小编为你收集整理的(document).height()、$(document).scrollTop()全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
(document).height()和$(window).height()、scrollTop
jQuery(window).height()代表了当前可见区域的大小
jQuery(document).height()则代表了整个文档的高度,可视具体情况使用
注意当浏览器窗口大小改变时(如最大化或拉大窗口后) jQuery(window).height() 随之改变,但是jQuery(document).height()是不变的。
$(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离 ,在chrome里面试了下,与$(window).scrollTop()得到的值相同
$(document).scrollLeft() 这是获取水平滚动条的距离
要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了
要获取底端 只要获取scrollTop()>=$(document).height()-$(window).height() 就可以知道已经滚动到底端了
$(document).height() //是获取整个页面的高度
$(window).height() //是获取当前 也就是你浏览器所能看到的页面的那部分的高度 这个大小在你缩放浏览器窗口大小时 会改变 与document是不一样的
今天的关于Python Selenium .execute_script("window.scrollTo(0, document.body.scrollHeight);") 不向下滚动的分享已经结束,谢谢您的关注,如果想了解更多关于$(window).scrollTop() 与 $(document).scrollTop()、$(window).scrollTop()和$(document).scrollTop()区别、(document).height()、$(document).scrollTop()、(document).height()和$(window).height()、scrollTop的相关知识,请在本站进行查询。
本文标签: