Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Aug 27, 2017 15:41

Problem

Extend the timeout on the RemoteWebDriver or AppiumDriver creation to avoid timeout when installing an application,

starting up multiple applications for Wind Tunnel testing, or performing download report (for large report files).

Solution

The constructor of the Selenium or Appium driver supports a timeout parameter in addition to the standard URL and DesiredCapabilities parameters.
By default, the timeout on the driver instantiation is set to 1 minute (60 seconds). However, if your capabilities include starting several applications, for example if you are using a Wind Tunnel persona, or if you specify a large application for installation by the Appium driver this may cause the processing to extend beyond this timeout period and you may receive the following exception dump (in Visual Studio/C#) from the test script:

Result StackTrace:
<< stack trace deleted >>          
ResultMessage:              Class Initialization
methodPerfectoLabSeleniumTestProject4.RemoteWebDriverTest.setUp threw exception.OpenQA.Selenium.WebDriverException:
OpenQA.Selenium.WebDriverException:
The HTTP request to the remote WebDriver server for URL
http://demo.perfectomobile.com/nexperience/perfectomobile/wd/hub/session/ac5bb37e-8037-42a0-af52-3e72b4444cf8/executetimed
out after 60seconds. ---> System.Net.WebException: The operation has timed out.

If the following message is included in the exception: timed out after 60seconds. --->System.Net.WebException: The operation has timed out. it is an indication that you need an extended driver creation timeout.

To define the longer timeout (for example 4 minutes) use the appropriate following format:

For C# or Java:

Using RemoteWebDriver:

driver = new RemoteWebDriver(url, capabilities, TimeSpan.FromMinutes(4));

Using Perfecto's RemoteWebDriverExtended class:

driver = new RemoteWebDriverExtended(new HttpAuthenticatedCommandExecutor(url,TimeSpan.FromMinutes(4)), capabilities);

Using Appium:

driver = new IOSDriver<IWebElement>(url, capabilities, TimeSpan.FromMinutes(4));

In Ruby:

The exception (Net::ReadTimeout) will be reported as:

##teamcity[testFailed name = 'WindTunnelExample.test_wind_tunnel_application_open' message = 'Net::ReadTimeout: Net::ReadTimeout' 
details = 'C:/Ruby22-x64/lib/ruby/2.2.0/net/protocol.rb:158:in `rescue in
rbuf_fill|'|n
<< stack trace deleted >>
error = 'true' timestamp = '2016-03-28T13:52:59.360+0300']

To set an extended RemoteWebDriver timeout in Ruby use the following:

# Increase client timeout to 5 minutes
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 300 # seconds
$driver = Selenium::WebDriver.for(:remote,:url => url, :desired_capabilities => caps,:http_client => client)