<!DOCTYPE html><html><head><styletype="text/css">div.scroll{
background-color:#00FFFF;
width:100px;
height:100px;
overflow:auto;
}</style></head><body><p>overflow:scroll</p><divclass="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.aaaaaaaaaaaaaaaaaaaaaaaaaaaa</div></body></html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
接下来我们用JS来控制里面的滚动条滚动:
from selenium import webdriver
dr=webdriver.Firefox()
dr.get('file:///D:/1.html')
js='document.getElementsByClassName("scroll")[0].scrollTop=10000'# 就是这么简单,修改这个元素的scrollTop就可以
dr.execute_script(js)