Skip to main content

Device Queries

Introduction

In general, Capabilities are series of key and value pairs that can customize or configure a device or browser session for testing to Selenium or Appium WebDriver.

Continuous Testing Cloud extends these capabilities with the Device Query capability. It is a special type of capability which describes one or more capabilities in a single query like input. 

The code snippet below is used to set Device Query using Selenium\Appium Java client bindings.

Device Query settings

/**
* Creates an Android Driver with Desired Capabilities.
*
*/
protected void createDriverWithCapabilities() {
LOGGER.info("Setting up Desired Capabilities");
String accessKey = System.getenv(ENV_VAR_ACCESS_KEY);

dc.setCapability(SeeTestCapabilityType.ACCESS_KEY, accessKey);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME,"iOS");
String deviceQuery = String.format("@os=android and @dhmlocation='us-1'", "android");
dc.setCapability(SeeTestCapabilityType.DEVICE_QUERY, deviceQuery);
AppiumDriver driver = new AndroidDriver(SeeTestProperties.SEETEST_IO_APPIUM_URL, dc) :
}

A few important observations can be made from the code sample.

  • The Device Query is set using the key SeeTestCapabilityType.DEVICE_QUERY.
  • Multiple capabilities can be set in one single query input, for example, device query="@os=android and @location='US', as opposed to the Appium capability which needs to be set one by one.
  • Property os overrides MobileCapabilityType.PLATFORM_NAME as they have the same meaning.

Supported Properties

Property NameProperty ValueExample or Possible Values
osOperating system.* iOS

* android
serialnumberSerial Number of the device.Unique identifier of the device in the SeeTest cloud.
versiondevice's operating system version (for example 4.1.2).Any Device version



Example: 4.1.2
versionnumberdevice's operating system version number (for example 4.1).Any Device version number



Example: 4.1
categorydevice category. Currently supported in android devices.* WATCH

* PHONE



* TABLET
modelNameDevice marketing nameExample: Galaxy S7 Edge
modelDevice modelExample: SM-G935F
dhmlocationLocation of the host machine as set in the SeeTestCloud configuration.Example: us-1
manufactureManufacturer of the device.Example: apple
nameKind of the deviceExample: iPhone 7
tagDevice tag (that was added by Cloud / Project administrator)Example: new_device
regionRegion of the device's DHMExample: Argentina

Syntax and Examples

Device Query is written in XPATH syntax, that is, @<propertyname>='<propertyvalue>' [ and @<propertyname>='<propertyvalue>' .....].

Device tags are added to query without @ character: tag='new_device'.

ExampleDescription
"contains(@dhmlocation,'us') and @manufacture='Samsung' and @os='android' and @version='4.2.2'* US location

* Samsung Manufacturer

* Android OS

* version 4.2.2
"@model='iphone' and @os='ios' and contains(@name, 'iPhone')"* iPhone model

* iOS

* Name contains 'iPhone'
"@model='iphone' and @os='ios' and starts-with(@name, 'iPhone')"* iPhone model

* iOS

* Name starts with 'iPhone'
@os='ios' and tag='new_device' and tag='released_2019'* iOS

* device has these tags: 'new_device' and 'released_2019'