Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Selenium Python在Whatsapp网页中滚动到聊天列表的末尾_Python_Selenium_Whatsapp - Fatal编程技术网

使用Selenium Python在Whatsapp网页中滚动到聊天列表的末尾

使用Selenium Python在Whatsapp网页中滚动到聊天列表的末尾,python,selenium,whatsapp,Python,Selenium,Whatsapp,我正在尝试使用selenium python向下滚动到Whatsapp网页聊天列表中的最后一个联系人 我收到以下错误消息: selenium.common.exceptions.JavascriptException: Message: javascript error: arguments[0].scrollIntoView is not a function (Session info: chrome=90.0.4430.212) 有时: selenium.common.excepti

我正在尝试使用selenium python向下滚动到Whatsapp网页聊天列表中的最后一个联系人

我收到以下错误消息:

selenium.common.exceptions.JavascriptException: Message: javascript error: arguments[0].scrollIntoView is not a function
  (Session info: chrome=90.0.4430.212)
有时:

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=90.0.4430.212)
代码如下:

#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)
我的问题:

如何在whatsapp网页中滚动至聊天列表的末尾请尝试以下代码:

driver.execute_script("var scrollingElement = (document.scrollingElement || document.body);scrollingElement.scrollTop = scrollingElement.scrollHeight;")