I am scrolling google maps reviews till end of scroll but I can't come outside of while loop. I am trying to scroll last height and new height after scrolling but it gives same.
output same height
2194
2194
2194
last_height = driver.execute_script("return document.documentElement.scrollHeight")
print(last_height)
while True:
scroller = driver.find_element_by_class_name('review-dialog-list')
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight',scroller)
sleep(3)
new_height= driver.execute_script("return document.documentElement.scrollHeight")
#new_height = driver.execute_script("return window.pageYOffset;")
print(new_height)
Finally I make a solution for this problem.
while True:
driver.execute_script("document.getElementsByClassName(\'review-dialog-list\')[0].scrollTo(0, document.getElementsByClassName(\'review-dialog-list\')[0].scrollHeight)")
sleep(5)
new_height = driver.execute_script("return document.getElementsByClassName(\'review-dialog-list\')[0].scrollHeight")
#print('new_height:', new_height)
if new_height == last_height:
break
else:
last_height = new_height
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.