uCodista
uCodista

Reputation: 111

Get current page load time setting Selenium Python

I need to get page load timeout for current driver object to be able to make something like this:

old_timeout = <get somehow current page load timeout value from self.driver>
new_timeout = 100
self.driver.set_page_load_timeout(new_timeout)
self.driver.get('https://stackoverflow.com')
self.driver.set_page_load_timeout(old_timeout)

In other words, I just want to get current timeout setting, change it to new one, do something and after that restore setting how it was. The only thing in this chain I don't know how to do - is to get current timeout setting.

I don't want to measure how long will it take to load page.

The idea is to change this setting for 1-time request and return it back how it was.

Thanks in advance.

Upvotes: 1

Views: 1675

Answers (1)

Guy
Guy

Reputation: 50854

There isn't a way to get the current timeout settings from the driver. You have two options:

  • If you initialize the driver in the same class keep the timeout in variable.
  • Create temporary driver and work with it

    temp_driver = self.driver
    temp_driver.set_page_load_timeout(100)
    temp_driver.get('https://stackoverflow.com')
    

Upvotes: 3

Related Questions