我试图向下滚动网页以避免“MoveTargetAutofBoundsException”,但无论我尝试什么,网页都只会向下滚动几英寸
以下是我尝试过但尚未奏效的解决方案:
#1
element = driver.find_element_by_xpath('//*[@id="advisor"]')
element.location_once_scrolled_into_view
#2
from selenium.webdriver.common.keys import Keys
html = browser.find_element_by_tag_name('html')
html.send_keys(Keys.END)
#3 No matter what number I use for Y, the scroll down will always be the same
driver.execute_script("window.scrollTo(0, Y)")
提前谢谢
元素存在于iframe中。您需要先切换它
您需要导入以下库
更新
这是完整的代码。要启用计算器按钮,您需要在金额文本框中输入值。但是正常的
webdriver
单击不起作用,因此使用了javascripts executor
快照:
在网页上向下滚动有多种方式。当前,您的网页上有ifrane,您需要将控件切换到iframe,然后再滚动到下面的代码部分,以获取参考:
1。您也可以使用此按钮向下滚动到页面底部。
2。您还可以使用
ActionChains
移动到元素3.基于身高
其中Y是高度(在全高清显示器上为1080)
工作代码:
相关问题 更多 >
编程相关推荐