Best way to handle
WebDriver code in the environment slowness. We have faced too many issues due
to slow environment for our website, in night when usage gone down then
WebDriver working perfectly but generally in day time when we have large usage
then it’s very hectic to handle even for the perfectly written scripts.
So, I used the pageLoadTimeout method that solves all the problem that we were
facing due to environment slowness. I used in the WebDriver instance initiate
so for each and every WebDriver command it always check for page load.
public static IWebDriver WebDriver
{
get
{
if (_webdriver == null)
_webdriver = GenericHelper.GetWebDriverInstance();
_webdriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(2));
return _webdriver;
}
}
You can
use other methods also as per your use.
WebDriver.Timeouts
|
implicitlyWait(long time,
java.util.concurrent.TimeUnit unit)
Specifies the amount of time the driver should
wait when searching for an element if it is not immediately present.
|
WebDriver.Timeouts
|
pageLoadTimeout(long time,
java.util.concurrent.TimeUnit unit)
Sets the amount of time to wait for a page load
to complete before throwing an error.
|
WebDriver.Timeouts
|
setScriptTimeout(long time,
java.util.concurrent.TimeUnit unit)
Sets the amount of time to wait for an
asynchronous script to finish execution before throwing an error.
|
No comments:
Post a Comment