Use regular expression to select a device for Selenium testing on BrowserStack Automate. Test on 3000+ devices on our real device cloud.
You can use regular expressions (regex) to select devices to test on, instead of providing specific device models in your capabilities. Based on the regex you pass, an available device is dynamically allocated from the available device pool that matches your specifications.
This approach not only affords you greater flexibility in test device selection, but also eliminates testing queues induced by device tier limits. Moreover, by broadening your search criteria using regular expressions, you can expedite your tests with an expanded device coverage, thereby enhancing test execution speed and efficiency.
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
Requirement
Description
Sample Values
deviceType
Optional
Specify the type of device
phone for phone or tablet for a tablet
Note: Please specify the platform or osVersion when using deviceType
deviceName
Required
Specify the device name or use regular expression, a matching device based on your specification will be allocated
To allocate devices between iPhone 10 and 11
To allocate any iPhone
To avoid allocation of Oppo or Huawei devices
- iPhone [10-11]
- iPhone.*
- ^(?=Oppo.*|Huawei.* ).*
The following code snippet demonstrates running a test on any Samsung Galaxy S series phone:
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.