A
A
aqau1232022-01-28 15:44:51
Python
aqau123, 2022-01-28 15:44:51

Why is stale error selenium crashing?

def collectArticle(self, link: str) -> None:
        """
        Goes through the posts on the given page and saves 'em screenshots, which will later on be used.
        """
        time.sleep(.2)    

        self.driver.get(link)

        self.driver.execute_script("document.body.style.zoom='80%'")

        self.wait.until(EC.presence_of_all_elements_located((By.XPATH, searchConfig.facebook['properties']['articles'])))
        self.wait.until(EC.element_to_be_clickable((By.XPATH, '//div[@role="main"]')))
        self.wait.until(EC.presence_of_element_located((By.XPATH, '//div[@role="main"]')))
        self.wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@role="main"]')))

        articles: List[WebElement] = self.driver.find_elements(By.XPATH, searchConfig.facebook['properties']['articles'])

        print(len(articles))

        for article in articles:
            try:
                time.sleep(2)
                self.ac.move_to_element_with_offset(article, 0, 100).perform()
                time.sleep(config.scrollTimePause)
                print(article)
                # self.takeScreenshot(article.screenshot_as_png, f'facebook{random.randint(1, 100)}.png')
            except sex.WebDriverException as e:
                print(e.msg)
                continue

Why is he getting a stail error? I am obviously waiting for this element, it is on the page, on the screen - too. I have even scattered time slips, you never know.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question