I am trying to scroll down to the last contact in Whatsapp Webpage chat list using selenium python.
I am receiving the following error message:
selenium.common.exceptions.JavascriptException: Message: javascript error: arguments[0].scrollIntoView is not a function
(Session info: chrome=90.0.4430.212)
and sometimes:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=90.0.4430.212)
Here is the code:
#Trial 1
# driver.execute_script("window.scrollTo(0, 1000);")
#Trial 2
# html = driver.find_element_by_tag_name('html')
# html.send_keys(Keys.END)
#Trial 3
# driver. execute_script("window.scrollTo(0,document.body.scrollHeight)")
#Trial 4
#This class is related to the side div
# test2 = driver.find_element_by_xpath("//div[@class='_1C2Q3 F-0gY']")
# driver.execute_script('arguments[0].scrollIntoView();',test2) #tried this
# test2.send_keys(Keys.PAGE_DOWN) # and also this
#Trial 5
#This class is related to the contacts
recentList = driver.find_elements_by_xpath("//span[@class='N2dUK']")
# driver.execute_script('arguments[0].scrollIntoView()',recentList) #tried this
for list in recentList :
# driver.execute_script("arguments[0].scrollIntoView();", list[:-1] )
# driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight', list)
# time.sleep(1)
# driver.execute_script("window.scrollTo(0, 500);")
# print('RECENT LIST')
print(list.text)
My question:
How to scroll to the end of the chat list in whatsapp webpage
try the below code:
driver.execute_script("var scrollingElement = (document.scrollingElement || document.body);scrollingElement.scrollTop = scrollingElement.scrollHeight;")
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.