Skip to content
Dor Blayzer edited this page Aug 18, 2024 · 5 revisions

DefaultCommandTimeout Field

Overview

The DefaultCommandTimeout field in the Appium .NET client specifies the default amount of time the AppiumDriver instance will wait for an HTTP request to complete. This is important for ensuring commands have enough time to execute, especially in environments with potential delays.

Note

Currently, the Appium .NET client derives this DefaultCommandTimeout field from the Selenium client, which has a default timeout of 1 minute (60 seconds). While this is generally sufficient for web-based sessions, it may not be enough for mobile sessions where operations can be slower due to factors like device performance, proxy timeout, network conditions, or the complexity of mobile interactions.

Tip

For this reason, increasing the timeout value when working with mobile sessions is advisable to prevent premature timeouts that could disrupt your test executions. A value of 600 seconds (10 minutes) should do.

General Usage Example

When initializing an AndroidDriver, you can specify a custom command timeout by passing it as a parameter during the driver's instantiation. Here’s a relevant example:

private readonly TimeSpan _initTimeoutSec = TimeSpan.FromSeconds(600.0);
_driver = new AndroidDriver(serverUri, capabilities, _initTimeoutSec);

In this example:

  • serverUri is the URI of the Appium server.
  • capabilities are the desired capabilities for the driver.
  • Env.InitTimeoutSec is a TimeSpan that specifies the custom timeout value. This setup allows you to control the command timeout dynamically based on the environment configuration, making your tests more flexible and adaptable to different conditions.