SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Add API to set page load timeout

Open 0xLeon opened this issue 5 years ago • 3 comments

Today, I stumbled upon the lack of ability to set the page load timeout defined by the W3C WebDriver standard [1]. The underlying Python Selenium implementation does provide a corresponding set_page_load_timeout method in selenium.webdriver.remote.webdriver.WebDriver [2].

Too me, it is not completely clear how this should be handled on the library level. SeleniumLibrary currently has two kinds of timeouts. The library timeout is both the library-own default timeout for the waiting keywords as well as the script timeout from the WebDriver standard. The implicit wait timeout is only a direct pass-through to the implicit wait timeout from the WebDriver standard. I don't know exactly why the WebDriver standard has a separate page load timeout, but it should be exposed on the library level as well, I think.

The question is, should SeleniumLibrary just use the existing library-level timeout for the page load timeout as well? This would mean that you basically loose the separation on the WebDriver level and have a single configuration parameter for script timeout and page load timeout.
The other solution would be to add another set of parameters and keywords for the page load timeout itself. This way, the separation from the WebDriver level is also exposed on the library level. But it would probably mean an API-breaking change is necessary, adding another parameter to the library __init__ as well as some more keywords specifically for the page load timeout.

[1] https://w3c.github.io/webdriver/#timeouts [2] https://github.com/SeleniumHQ/selenium/blob/5d0099de8401c3e5b58f58bd227c46d95da7c8a7/py/selenium/webdriver/remote/webdriver.py#L967

0xLeon avatar Jan 08 '20 15:01 0xLeon

One more note: I'd be happy to provide a pull request for either solution, but I can't say for sure when this would be possible due to the necessary code contribution approval process from my employer.

0xLeon avatar Jan 08 '20 15:01 0xLeon

Page load timeout is (usually) bigger than the other timeouts in the library. Usually current timeouts are less then 60 seconds (more close to 15 seconds in my usual use) and page load timeout can be multiple of minutes. Of course this highly depends on the web application performance and numerous other factors.

At least we should add keyword to set the page load timeout, in similar functionality Set Selenium Timeout. But should page load timeout be also library level import? It is question which does not have clear answer. Page load timeout is not needed that often than other timeouts, but for consistency reason it would be good to have in the library init. I would say that consistency is good thing in this matter and lets add it in the library init too.

This might hard to test in the acceptance test, but it might be easy to test in the unit test.

aaltat avatar Jan 08 '20 16:01 aaltat

Hi, @0xLeon Do you have any work around or possible solution you could share?!

ricardomaximino avatar Sep 21 '21 15:09 ricardomaximino