selenium-自动化测试之模拟页面滚动

版权声明:本文为博主原创文章,转载请附上博文链接 https://blog.csdn.net/weixin_44065501/article/details/89314961

在自动化测试当中,页面的滚动是比较常用的

第一种:滚动到底部
browser.execute_script("var action=document.documentElement.scrollTop=10000")
time.sleep(1)
第二种:滚动到顶部
browser.execute_script("var action=document.documentElement.scrollTop=0")
time.sleep(1)

注意:在自动化测试当中,页面寻找元素,一般只会从头到尾顺序查找,不支持逆向查找,所以,当我们随机点击页面时,每次滚动到底部之后,都需要先返回到顶部,再进行下一次元素的查找

猜你喜欢

转载自blog.csdn.net/weixin_44065501/article/details/89314961