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
osoverridesMobileCapabilityType.PLATFORM_NAMEas they have the same meaning.
Supported Properties
| Property Name | Property Value | Example or Possible Values |
|---|---|---|
| os | Operating system. | * iOS * android |
| serialnumber | Serial Number of the device. | Unique identifier of the device in the SeeTest cloud. |
| version | device's operating system version (for example 4.1.2). | Any Device version Example: 4.1.2 |
| versionnumber | device's operating system version number (for example 4.1). | Any Device version number Example: 4.1 |
| category | device category. Currently supported in android devices. | * WATCH * PHONE * TABLET |
| modelName | Device marketing name | Example: Galaxy S7 Edge |
| model | Device model | Example: SM-G935F |
| dhmlocation | Location of the host machine as set in the SeeTestCloud configuration. | Example: us-1 |
| manufacture | Manufacturer of the device. | Example: apple |
| name | Kind of the device | Example: iPhone 7 |
| tag | Device tag (that was added by Cloud / Project administrator) | Example: new_device |
| region | Region of the device's DHM | Example: 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'.
| Example | Description |
|---|---|
| "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' |