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 Define 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 Perfecto. You can also use the Manual Testing view in the Perfecto UI to automatically generate capabilities for the selected device.
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 Perfecto, remember to activate the following:
The setExecutionIdCapability() method, supplied as part of the Eclipse template, informs Perfecto 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:
Use Perfecto 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 Perfecto 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 (such as 5.0.1, 8.3)
- Device model (such as Nexus, iPad, Galaxy) or manufacturer (such as 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 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 "5.0.*" as the OS Version, it will match 5.0.1/5.0.2 and so on. If you use the string "8.", 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).
To specify capability values with special characters, use the backslash (\) as an escape character to prevent special characters from being read as part of regular expressions. For example, because the plus character (+) has a special meaning inside regular expressions, to select the device model Galaxy Note10+, specify the capability value as follows:
capabilities.setCapability("model", "Galaxy Note10\\+");
The following code requests that Perfecto automatically select a device using a sub-version of the Android 5.2 operating system.
The following code requests that Perfecto select an available Samsung Galaxy running Android 5 or Android 6:
The following code requests that Perfecto select an iPhone (not iPad) device running either iOS 8.3 or 8.4.
You can 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: