Default value for timeouts in selenium webdriver

I'm interested in the default timeout value for selenium webdriver. ImplicitlyWait webdriver. ImplicitlyWait , SetPageLoadTimeout and SetScriptTimeout . Because I want to know if I need to set values ​​for these timeouts? or the default value is useful for selenium webdriver to work. But I can not find the right answer, someone says that the default value is 0, and the other is 30 seconds.

+11
selenium selenium-webdriver
source share
3 answers

These three timeouts are controlled by the server side of the Selenium equation. Your script, whether it be Java, Python, Ruby, C # or any other, is a client that sends commands to a server that lives in a browser. (There may be an intermediary that sends commands to the browser, for example, Selenium grid. Unfortunately, it is also sometimes called the "server".)

The WebDriver specification that was obtained from Selenium is based on the following values:

  • For implicit expectations: 0 seconds. This means that if the selenium command does not find the item immediately, it reports immediately, rather than waiting for the item to be found.

  • To load the page: 300 seconds.

  • For script timeout: 30 seconds.

(The specification gives values ​​in milliseconds. I converted them to seconds for readability.)

Selenium now follows the WebDriver specification.


However, in the past, Selenium used other meanings for them. For example, the Firefox driver used its timeout as follows:

  • The implicit wait time is set to 0 by default. This means that if the command that finds the elements does not find anything, it will not wait.

  • The default page load timeout is -1. This means that Selenium will endlessly wait for the page to load.

    What Sayfur discovered is different from the wait time for the page to load. This is a timeout between the Selenium client and the Selenium server, which is not well explained on the page found by Sayfur.

  • The default script timeout is 0. A comment in the source code explains:

    The time, in milliseconds, during which a session should wait for asynchronous scripts to complete. If set to 0, the timeout will not fire until the next event loop after the script is executed. This will give scripts that use a 0-based setTimeout to complete.

    Thus, even if it is set to zero, the asynchronous script can still be executed, but it must be completed before the Selenium timeout gets a chance to restart.

This is from the code that Selenium uses for Firefox. Other browsers use different code bases, but it is assumed that they behave in a consistent manner, at least with respect to things that match Selenium itself, such as these timeouts. Thus, the meanings and their interpretations should be the same for other browsers.

+16
source share

For implicit wait, always by default expect it to ZERO., You can check it here:

Selenium Webdriver diff. is waiting

And if you set the user time, then the web driver will wait to receive the item until this time, and if the item is not found before this time, then only the web driver will throw an exception.

0
source share

Selenium's documentation is very unclear regarding these timeouts.

  • According to this , the default timeout for implicit wait is 0
  • According to this, any page that does not load in the 60s will return a timeout http link if you did not explicitly rewrite the timeout.
  • Unfortunately, I did not find a link to ScriptTimeout. But by default, this value is 0 and experience. Will update you with any links later.
0
source share

All Articles