When using Selenium WebDriver, there is a method called setScriptTimeout(time, unit)
. The description of this method states that it
Specifies the time allowed for an asynchronous script to finish executing before an error is thrown. If the timeout is set to negative, the script can run indefinitely.
I have two questions regarding this method -
- I am unclear on when exactly this method should be used. It would be greatly appreciated if someone could provide an example for better understanding
- If a specific time is set for
setScriptTimeout
, does each Selenium command (such as locating elements or clicking) wait for all page JavaScripts to finish execution within the specified timeframe?