S
S
Sergey Alekseev2019-08-04 06:25:00
Python
Sergey Alekseev, 2019-08-04 06:25:00

Python Selenium, why does WebDriver freeze when switching to second tab?

Good morning, I create a driver:

class ChromeBrowser(BaseBrowser, IBrowser):
    def create_driver(self):
        options = ChromeOptions()
        options.add_argument('--headless')
        options.add_argument('--disable-gpu')

        self.driver = Chrome(chrome_options=options)

    def close_driver(self):
        self.driver.close()

Then on the first tab I normally look for page elements, for example:
login = self.browser.driver.find_element_by_css_selector("input[id='login']")
password = self.browser.driver.find_element_by_css_selector("input[id='passwd']")

But when a new tab opens and I switch to it:
self.browser.driver.switch_to.window(self.browser.driver.window_handles[1])

And after that I try to search for an element, after 5 minutes a timeout exception flies
How to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LayzyTeh, 2019-08-04
@LayzyTeh

Have you tried adding multithreading?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question