Search Here!

Friday, September 14, 2012

WebDriver Handling Environment Slowness

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
                if (_webdriver == null)
                    _webdriver = GenericHelper.GetWebDriverInstance();
                return _webdriver;

You can use other methods also as per your use.

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.
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.
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