R
R
r1mple2022-01-08 17:35:16
Python
r1mple, 2022-01-08 17:35:16

Why doesn't driver.get() work?

driver.get() stopped opening links, he first opens it, and then everything, why does this happen?
Code snippets where this happens.
There is a login () method, it opens the Facebook login page, everything is ok there, but then, after generating links, when you try to access the link, nothing happens.

class Facebook:
    def __init__(self) -> None:
        s = seleniumdriver.SeleniumDriver(
            headers="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
                    "Chrome/97.0.4692.71 Safari/537.36",
            headless=False
        )

        prefs = {"credentials_enable_service": False,
                 "profile.password_manager_enabled": False}

        s.options.add_experimental_option("prefs", prefs)

        s.initDriver(config.CHROMEDRIVER)

        self.driver = s.driver

        self.waitTime = 10

        self.wait = WebDriverWait(self.driver, self.waitTime)
        self.ac = ActionChains(self.driver)

    def getKeywordGroups(self, links: List[str]) -> List[str]:
        """
        Just goes through the given list of urls and finds all them groups on thee facebook pages.
        It goes on the page, scrolls to the very end, loads all the stuff on the page, and loops through it
        collecting all the data.

        :param links:
        :return list containing links to the found groups:
        """
        for link in links:
            print(1)
            self.driver.get('https://google.com')

            try:
                self.wait.until(EC.presence_of_element_located((By.XPATH, searchConfig.properties['keywordsFeed'])))
            except exceptions.TimeoutException:
                print(f'Could not find feed in {self.waitTime} seconds. Probably it\'s not have been loaded. {link=}.\n'
                      'Check your internet connection.')
                continue

            print(f'URL: {link}')

            self.wait.until(EC.presence_of_element_located((By.XPATH, searchConfig.properties['group'])))

            self.scroll()

            groups = self.driver.find_elements(By.XPATH, searchConfig.properties['group'])

            print(f'Managed to find {len(groups)} groups on this page.')

            return self.collectGroups(groups)

in the getKeywordLinks() method, in the gete driver, you can write anything you like, but it still won’t work, for some reason it prints 1 to the console, but doesn’t follow the link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aqau123, 2022-01-10
@aqau123

add a time slip of 0.3-0.5 before calling the get driver.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question