Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: How to scroll in inner div using selenium in python

Want to scroll the chats in web.whatsapp.com. 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.com till the last chat.

Thanks in advance!

like image 851
Alok Saumya Avatar asked Mar 07 '23 06:03

Alok Saumya


1 Answers

try 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
like image 184
Ankur Singh Avatar answered Apr 07 '23 10:04

Ankur Singh