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

Last updated: Oct 10, 2019 13:45

Perfecto's RWD and Appium implementation uses driver capabilities to automatically open the device for the test script.

Perfecto supports different driver capabilities for the RemoteWebDriver and Appium drivers as described in the post on defining capabilities. These include a set of capabilities defined by the Perfecto Lab to select the device to use for the test script.

Select a specific device

If you are running your script on a specific device, whose device ID is known you can use the following capability setting to specify this to the Perfecto Lab:

capabilities.setCapability("deviceName", "12345678"); // supply the device ID

* This and the additional code snippets are applicable to C# by substituting "SetCapability" for "setCapability" as shown in the following example:

capabilities.SetCapability("deviceName", "12345678"); // supply the device ID

If you are running your test while the device is open in the PerfectoLab window, remember to activate the following:

setExecutionIdCapability(capabilities);

The setExecutionIdCapability() method, supplied as part of the Eclipse template, informs the Perfecto Lab that the device is already open and it should not attempt to reopen the device (which may cause an exception).

* For Visual Studio C# users the equivalent method is supplied as an extension to the DesiredCapabilities class and the following invocation is supplied as part of the project template:

capabilities.SetPerfectoLabExecutionId(host);

Use Perfecto Lab auto-selection

The limitation in using a specific device is that sometimes the device may be busy running a different script or may be disabled. The better option for scripts running automatically is to supply the necessary device characteristics and let the Perfecto Lab automatically select the device from the available devices. When the test script does not define a specific device, Perfecto selects a leading device for testing. This is the default configuration in public cloud instances. For private clouds, Perfecto Support can configure leading devices upon request.

The leading devices feature ensures that your tests always run again the most relevant, stable, popular devices with the highest possible OS version. If a leading device is not available, Perfecto selects the device with the highest OS version instead. For details, see Auto-selection of leading devices.

Capabilities allow you to specify the following device characteristics:

  • Operating system (Android or iOS) and particular version (e.g. 5.0.1, 8.3)
  • Device model (e.g. Nexus, iPad, Galaxy) or manufacturer (e.g. LG, Samsung)
  • Resolution, Location, or Network.

When supplying the capability value, you can use Java regular expressions to generalize the capability value. For example the following can be used:

  • The period ('.') matches any character.
  • The asterisk ('*') matches any repetition of the previous character.
  • Characters within square brackets ("[]") match any single character.

Therefore, if you use the "5.0.*" as the OS Version it will match 5.0.1/5.0.2 etc. If you use the string "8.[346]" it will match 8.3/8.4/8.6 but not 8.5! If you use the string "iPad.*" for the model capability this will match any model of the iPad (including iPad Mini). More information on Java regular-expressions can be found at various Java tutorial sites (for example, tutorialspoint.com)

The following code requests that the Perfecto Lab automatically select a device using a sub-version of the Android 5.2 operating system.

capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "5.2.*");

The following code requests that the Perfecto Lab select an available Samsung Galaxy running Android 5 or Android 6:

capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "[56].*");
capabilities.setCapability("manufacturer", "Samsung");
capabilities.setCapability("model", "Galaxy.*");

The following code requests that the Perfecto Lab select an iPhone (not iPad) device running either iOS 8.3 or 8.4

capabilities.setCapability("platformName", "ios");
capabilities.setCapability("platformVersion", "8.[34].*");
capabilities.setCapability("model", "iPhone.*");

Add a timeout capability to wait for a device, when selecting a device according to device attributes and no matching device is available when the script starts running. The timeout should be up to 15 minutes. For example:

capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "5.2.*");
capabilities.setCapability("openDeviceTimeout", 5);