Use regular expression to specify device attributes
You can use regular expressions (regex) to select devices to test on instead of providing specific device models in the deviceName
(W3C protocol) or device
(JSON wire protocol) capability and OS versions in the platformVersion
(W3C protocol) or os_version
(JSON wire protocol) capability. Based on the regex you pass, an available device is allocated from the device pool that matches your specifications. By widening your search through regular expressions, you get better test execution speed by reducing queuing and device tier limits.
The following table provides information on how to use regular expression for specifying device attributes:
Capability | Required/Optional | Description | Sample Values |
---|---|---|---|
platformName |
Required | Specify the mobile operating system that you wish to test on |
android or ios
|
deviceName |
Required | Specify the device name or use regular expression, a matching device based on your specification will be allocated |
Samsung .* allocates any Samsung device iPhone [67]$ allocates iPhone 6 or iPhone 7 |
platformVersion |
Optional | Provide major OS version or range of OS versions using regex |
1[012] allocates version 10 , 11 or 12
|
deviceType |
Optional | Specify the type of device |
phone for phone or tablet for a tablet |
platfromVersion
or os_version
capabilities
Example
The following code snippet demonstrates running a test on any Samsung Galaxy S series phone with an Android version between 10 and 12:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "android");
capabilities.setCapability("deviceName", "Samsung Galaxy S.*");
capabilities.setCapability("platformVersion", "1[012]");
var capabilities = {
"platformName" : "android",
"deviceName" : "Samsung Galaxy S.*",
"platformVersion" : "1[012]",
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
capabilities.AddAdditionalCapability("platformName", "android");
capabilities.AddAdditionalCapability("deviceName", "Samsung Galaxy S.*");
capabilities.AddAdditionalCapability("platformVersion", "1[012]");
desired_cap = {
"platformName" : "android",
"deviceName" : "Samsung Galaxy S.*",
"platformVersion" : "1[012]",
}
capabilities = {
"platformName" => "android",
"deviceName" => "Samsung Galaxy S.*",
"platformVersion" => "1[012]",
}
If you are using BrowserStack’s SDK as your integration method, then you can also use regex in your browserstack.yml
file to specify device attributes as shown below:
platforms:
- platformName: android
deviceName: Samsung Galaxy S.*
platformVersion: 1[012]
Capability | Required/Optional | Description | Sample Values |
---|---|---|---|
os |
Required | Specify the mobile operating system that you wish to test on |
android or ios
|
device |
Required | Specify the device name or use regular expression, a matching device based on your specification will be allocated |
Samsung .* allocates any Samsung device iPhone [67]$ allocates iPhone 6 or iPhone 7 |
os_version |
Optional | Provide major OS version or range of OS versions using regex |
1[012] allocates version 10 , 11 or 12
|
deviceType |
Optional | Specify the type of device |
phone for phone or tablet for a tablet |
platfromVersion
or os_version
capabilities
Example
The following code snippet demonstrates running a test on any Samsung Galaxy S series phone with an Android version between 10 and 12:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platform", "android");
capabilities.setCapability("device", "Samsung Galaxy S.*");
capabilities.setCapability("os_version", "1[012]");
var capabilities = {
"platform" : "android",
"device" : "Samsung Galaxy S.*",
"os_version" : "1[012]",
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
capabilities.AddAdditionalCapability("platform", "android");
capabilities.AddAdditionalCapability("device", "Samsung Galaxy S.*");
capabilities.AddAdditionalCapability("os_version", "1[012]");
desired_cap = {
"platform" : "android",
"device" : "Samsung Galaxy S.*",
"os_version" : "1[012]",
}
desired_caps = {
"platform" => "android",
"device" => "Samsung Galaxy S.*",
"os_version" => "1[012]",
}
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!