1

class accinfo:

def getfolowing(acclink,foldername1):
    time.sleep(2)
    profileurl = "https://instagram.com/" + (acclink) + "/"
    browser.get(profileurl)
    time.sleep(2)
    wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="react-root"]/section/main/div/header/section/ul/li[3]/a/div'))).click()
    time.sleep(3)





    following = browser.find_elements(By.CLASS_NAME,"notranslate._0imsa ")
    accinfo.scroldownfolwr()
    path = "C:\\Users\\ayarb\PycharmProjects\instagrambotv1" + "\\" + foldername1
    os.chdir(path)
    followingls = open("followinglist.txt","a")
    for followingt in following:
        print(followingt.text)
        followingls.write(followingt.text)
        followingls.wirte("\n")
        break




def scroldownfolwr():
    jsscrolldown = """
    
    sayfa = document.querySelector(".isgrP");
    sayfa.scrollTo(0,sayfa.scrollHeight);
    var sayfasonu = sayfa.scrollHeight;
    
    """
    sayfasonu = browser.execute_script(jsscrolldown)
    while True:
        son = sayfasonu
        time.sleep(1)
        sayfasonu = browser.execute_script(jsscrolldown)
        if son == sayfasonu:
            break

why im getting this error

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

0 Answers0