Want to scroll the chats in web.whatsapp. Have shared the pseudo-code below:
recentList = driver.find_elements_by_xpath("//div[@class='_2wP_Y']")
driver.execute_script("window.scrollTo(0, 500);")
Looking forward for a solution so as to scoll in web.whatsapp till the last chat.
Thanks in advance!
Want to scroll the chats in web.whatsapp.. Have shared the pseudo-code below:
recentList = driver.find_elements_by_xpath("//div[@class='_2wP_Y']")
driver.execute_script("window.scrollTo(0, 500);")
Looking forward for a solution so as to scoll in web.whatsapp. till the last chat.
Thanks in advance!
Share Improve this question edited Dec 29, 2017 at 20:18 Rohit Rai 3754 silver badges21 bronze badges asked Dec 29, 2017 at 19:35 Alok SaumyaAlok Saumya 691 gold badge1 silver badge7 bronze badges5 Answers
Reset to default 8try below code
recentList = driver.find_elements_by_xpath("//div[@class='_2wP_Y']")
for list in recentList :
driver.execute_script("arguments[0].scrollIntoView();", list )
// other operation
Try this:
eula = driver.find_elements_by_xpath("//div[@class='_2wP_Y']")
for my_xpath in eula:
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight', my_xpath)
time.sleep(1)
Below is a simple approach which worked for me when none of the other answers did.
First make sure you are selecting the div with the "scrollbar" element.
scrolling_element= find_element_by_xpath(scrolling_element_xpath)
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight', scrolling_element)
Solution with Python only (using hTouchActions
class' scroll_from_element
method):
from selenium.webdriver.mon.touch_actions import TouchActions
recent_list = driver.find_elements_by_xpath("//div[@class='_2wP_Y']")
touch_action = TouchActions(driver)
touch_action.scroll_from_element(recent_list[1], 0, 150).perform()
element
should be a scrollable element
driver.execute_script("arguments[0].scroll(0,arguments[0].scrollHeight);", element)