Running Automated Tests on Shared Devices
Shared Devices support automation using Appium. Visit the Appium section to learn more about automation.
Running automated tests on Shared Devices doesn’t require changes to your script—just minor setup adjustments to target Shared Devices.
Test Setup Example
Here’s an example setup for reserving a Samsung device running a native application:
@BeforeMethod
public void setup() throws MalformedURLException {
UiAutomator2Options options = new UiAutomator2Options();
options.setCapability("testName", "AndroidNativeTest");
options.setCapability("accessKey", ACCESS_KEY);
options.setCapability("deviceQuery", "@os='android' and @modelName='Samsung Galaxy S24'");
options.setCapability("platformName", "Android");
options.setCapability("app", "cloud:com.experitest.ExperiBank/.LoginActivity");
options.setCapability("appPackage", "com.experitest.ExperiBank");
options.setCapability("appActivity", ".LoginActivity");
options.setCapability("automationName", "UiAutomator2");
driver = new AndroidDriver(new URL(CLOUD_URL), options);
}
The example uses Java, but Shared Devices work with any language supported by Appium.
To specify that this test runs on a Shared Device, include the capability devicePool
:
options.setCapability("devicePool", "shared");
Capability Name | Accepted Values (String) | Description |
---|---|---|
devicePool | shared, dedicated, any | shared : Targets devices only from the shared pool.dedicated : Targets devices only from the dedicated pool.any : Prioritizes devices from the dedicated pool.If no devices or licenses are available, it will look in the shared pool. |
Duration of a Reservation
When running automated tests on Shared Devices, the session duration will default to the duration defined for Dedicated Devices with a 24 hour limit.
Refer to Device Reservations Management for more details.
To adjust the reservation duration for your automated test(s), use the reservationDuration
capability:
options.setCapability("reservationDuration", 60);
Capability Name | Accepted Values (Integer) | Description |
---|---|---|
reservationDuration | Integer value | Adjusts the reservation duration for automated tests. The value is specified in minutes. For example, the value 60 represents 1 hour. |
If the reservationDuration
exceeds the ‘maximum allowed’ by your platform configuration, a message will be displayed from your execution instance:
SessionNotCreatedException: Unable to create a new remote session. Original error: Could not start test. Reservation time in minutes too long. Following value was provided: 7000
Releasing a Shared Device
When an automated test finishes on a Shared Device and driver.quit() is called, the device is released, and a cleanup process is initiated.
If you’d like to keep the session active for subsequent tests without releasing the device (to speed up session initiation), use releaseDevice
capability:
options.setCapability("releaseDevice", False);
Capability Name | Accepted Values (Boolean) | Description |
---|---|---|
releaseDevice | True, False | By default, this is set to True . Setting it to False will keep the device session active and prevent it from being released. |
Note: It’s recommended to include a final dummy test with releaseDevice=True after completing all your tests. This ensures that the device session is released properly; otherwise, the device will remain reserved for the rest of the session duration.
License Note: A shared device license is released only when the reservation ends, whereas a dedicated device license is released immediately after the session ends.