[英]can I scroll a web page using selenium webdriver in python
browser = webdriver.Firefox()
browser.get('http://www.example.com')
search_items = []
for i in range(0, 20):
items = browser.find_element_by_xpath(
'//*[@id="asrt%s"]/section[2]'
% str(i))
driver.items("window.scrollTo(0, Y)")
print items.text
If you are looking to scroll to a WebElement you can use: 如果要滚动到WebElement,可以使用:
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", element);
Where element is the variable to a WebElement you have set. 其中element是您设置的WebElement的变量。
you can use 您可以使用
driver.execute_script("window.scrollTo(0, Y)") driver.execute_script(“ window.scrollTo(0,Y)”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.