OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why my scrollbar in Instagram doesn't work?

  • Thread starter Thread starter Y B
  • Start date Start date
Y

Y B

Guest
I'm working on a Instagram autosub project. It's a dynamic website, so I would need to scroll down. I know how to do this in the MAIN window, but since Interest are a pop-up window this solution to scroll doesn't work.

Code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

chrome_option = webdriver.ChromeOptions()
chrome_option.add_experimental_option("detach", True)

driver = webdriver.Chrome(options=chrome_option)
driver.get(url="https://www.instagram.com/accounts/login")

USER = "USER"
EMAIL = ("EMAIL")
PASSWORD = "PASSWORD"

try:
    cookies = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Allow all cookies')]"))
    )
    cookies.click()

    enter_email = driver.find_element(By.XPATH, value='//input[@name="username"]')
    enter_email.send_keys(EMAIL)

    enter_password = driver.find_element(By.XPATH, value='//input[@name="password"]')
    enter_password.send_keys(PASSWORD)
    enter_password.send_keys(Keys.ENTER)

    not_now = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.CSS_SELECTOR, "div ._ac8f div"))
    )
    not_now.click()

    not_now2 = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, '//button[contains(text(), "Not Now")]'))
    )
    not_now2.click()

    driver.get(url=f"https://www.instagram.com/{USER}/")

    follows = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, "//a[contains(@href, '/following')]"))
    )
    follows.click()

    fBody = driver.find_element(By.XPATH, "//html/body/div[6]/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[4]']")
    scroll = 0
    while scroll < 5:
        driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
        time.sleep(2)
        scroll += 1

except Exception as e:
    print(e)

I've looked at stachoverflow, asked the GPT chat, looked at a bunch of videos, but nothing's helped.

Selenium Python: How to Scroll Down in a Pop Up window Why scroll on modal/popup doesn't working on instagram Even these didn't help.

Could it be just a problem with this version of Instagram?
<p>I'm working on a Instagram autosub project. It's a dynamic website, so I would need to scroll down. I know how to do this in the MAIN window, but since Interest are a pop-up window this solution to scroll doesn't work.</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

chrome_option = webdriver.ChromeOptions()
chrome_option.add_experimental_option("detach", True)

driver = webdriver.Chrome(options=chrome_option)
driver.get(url="https://www.instagram.com/accounts/login")

USER = "USER"
EMAIL = ("EMAIL")
PASSWORD = "PASSWORD"

try:
cookies = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Allow all cookies')]"))
)
cookies.click()

enter_email = driver.find_element(By.XPATH, value='//input[@name="username"]')
enter_email.send_keys(EMAIL)

enter_password = driver.find_element(By.XPATH, value='//input[@name="password"]')
enter_password.send_keys(PASSWORD)
enter_password.send_keys(Keys.ENTER)

not_now = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "div ._ac8f div"))
)
not_now.click()

not_now2 = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//button[contains(text(), "Not Now")]'))
)
not_now2.click()

driver.get(url=f"https://www.instagram.com/{USER}/")

follows = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//a[contains(@href, '/following')]"))
)
follows.click()

fBody = driver.find_element(By.XPATH, "//html/body/div[6]/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[4]']")
scroll = 0
while scroll < 5:
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
time.sleep(2)
scroll += 1

except Exception as e:
print(e)
</code></pre>
<p>I've looked at stachoverflow, asked the GPT chat, looked at a bunch of videos, but nothing's helped.</p>
<p><a href="https://stackoverflow.com/questions/45961116/selenium-python-how-to-scroll-down-in-a-pop-up-window">Selenium Python: How to Scroll Down in a Pop Up window</a>
<a href="https://stackoverflow.com/questions/67525231/why-scroll-on-modal-popup-doesnt-working-on-instagram">Why scroll on modal/popup doesn&#39;t working on instagram</a>
Even these didn't help.</p>
<p>Could it be just a problem with this version of Instagram?</p>
 

Latest posts

Top