Andrew
Andrew

Reputation: 1575

How to scroll down inside followers popup on Instagram?

How can i properly use scroll function inside Instagram popup. enter image description here

I used js function to scroll , which didnt worked

window.scrollBy(0,800);

via Imacros

EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY" KEY=34

As well before scroll event used to click between users to make popup active and then used scroll, before it worked but for now it's not.

Is there any proper way to scroll inside popup?

Upvotes: 1

Views: 1792

Answers (3)

mohan-sah
mohan-sah

Reputation: 1

Locate the Followers Section:

finding_that_follower = self.driver.find_element(By.XPATH, '//h1[text()="Followers"]')

Navigate to the Parent Container:

going_three_generation_up = finding_that_follower.find_element(By.XPATH, '../../..')

This step is necessary because class names are dynamically generated, making it essential to traverse up the DOM to access the parent container where the scrollable dialog is present

Methods to Handle Scrolling in a Dialog:

  • sleep(2) # Optional: Wait for the modal to load self.driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", modal)

  • from selenium.webdriver.common.keys import Keys modal.send_keys(Keys.END)

  • from selenium.webdriver.common.action_chains import ActionChains actions = ActionChains(self.driver) actions.move_to_element(modal).click().send_keys(Keys.END).perform()

NOTE:here, i am assuming that modal is selected

Upvotes: 0

Daniel
Daniel

Reputation: 5

This works for me in 2019... Don't change anything!

FList = driver.find_element_by_css_selector('div[role=\'dialog\'] ul')
numberOfFollowersInList = len(FList.find_elements_by_css_selector('li'))

FList.click()
actionChain = webdriver.ActionChains(driver)
time.sleep(random.randint(2,4))

while (numberOfFollowersInList < max):
    actionChain.key_down(Keys.SPACE).key_up(Keys.SPACE).perform()        
    numberOfFollowersInList = len(FList.find_elements_by_css_selector('li'))
    time.sleep(0.4)
    print(numberOfFollowersInList)
    actionChain.key_down(Keys.SPACE).key_up(Keys.SPACE).perform()            
    time.sleep(1)

Upvotes: 0

Shugar
Shugar

Reputation: 5299

I think the following command may be helpful:

EVENT TYPE=KEYPRESS SELECTOR="div.j6cq2" KEY=34

Upvotes: 2

Related Questions