[英]How to scroll in an element using selenium in python
I've been searching for a while to find a way to scroll in an element using selenium. 我已经搜索了一段时间,以找到一种使用硒滚动元素的方法。 I'm already able to scroll up and down the web page, but I haven't found a way to use the scroll bar inside an element.
我已经可以在网页上上下滚动,但是还没有找到在元素内使用滚动条的方法。 I was wondering if anyone else knew how to do it.
我想知道是否还有其他人知道该怎么做。
You can use execute_script
, for example, if we go to a random pastebin link ( https://pastebin.com/en0f652r ) and use the code below, it will scroll down the pasted code window. 您可以使用
execute_script
,例如,如果我们转到随机的pastebin链接( https://pastebin.com/en0f652r )并使用下面的代码,它将向下滚动粘贴的代码窗口。
driver.execute_script("$('#paste_code').animate({scrollTop: '100px'})")
Replace "#paste_code" with the scroll bar element you are wishing to scroll. 将“ #paste_code”替换为您希望滚动的滚动条元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.