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 code snippet demonstrates running a test on any Samsung Galaxy S series phone with an Android version between 10 and 12:
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:
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
Note the following while using the platformVersion capability:
Minor and patch OS versions are not honored in the platformVersion capability.
Escape characters are not supported.
You can run tests on a wider set of devices. For example, to run tests on any Samsung Galaxy S series device refer to the following syntax:
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.