2

I am trying to scroll through the scroll bar that appears when I click likes on my photos on instagram and get the profiles that liked each photo. Unfortunately I am having trouble targeting the dialog box.

Here is the html code:

<div class="pbNvD  fPMEg   " role="dialog">
    <div class="                   Igw0E     IwRSH      eGOV_  vwCYk"style="max-height: 356px; min-height: 200px;">
         <div style="height: 356px; overflow: hidden auto;">
         </div>
    </div>
<div>

Here is the code that I have tried so far but while there is no error, it does not scroll:

fBody  = driver.find_element_by_xpath("//div[@class='pbNvD  fPMEg   ']")
scroll = 0
fList = []


n = 0
while n < 5: # scroll 5 times
    n = n +1
    driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
    time.sleep(1)
Artur Podlesniy
  • 145
  • 1
  • 7

1 Answers1

0

If you always want to scroll to the end of the page,the easiest way to do is:

fBody.send_keys(Keys.END)

Another one if you want to scroll down to one page only:

fBody.send_keys(Keys.PAGE_DOWN)

More details here: https://stackoverflow.com/a/27760083/6042903

Muhammad Haseeb
  • 634
  • 5
  • 20