I am trying to make web page automation where I am using selenium in python3.6. I have done most of it, I just have to scroll down a page which is static. To scroll down the page I am first getting the height of the page and then doing:
while True:
height = driver.execute_script("return document.body.scrollHeight")
scroll = 100
time.sleep(2)
while scroll < height:
driver.execute_script("window.scrollTo(0," + str(scroll) + ");")
scroll = int(scroll) + 100
time.sleep(3)
This is working fine but the only issue with this is that it scrolls a bit faster. Yes I can increase the time.sleep() but I want to control the scroll speed here. Is it possible with selenium. Thanks
Also, if can anyone point any wrong thing I am doing with above code
Aucun commentaire:
Enregistrer un commentaire