Using a service like BrowserStack you can take your local automation tests to the skies. This is made possible by directing CodeceptJS to point to BrowserStack instead of running locally.
The BrowserStack service required is Automate, which runs tests using appium libraries on a plethora of mobile devices and operating systems. It also records tests by default, allowing you to review each scenario once complete.
To do so, you'll need to upload your mobile app. When successful, you'll receive an app_url
in the response, which is the url to access the app in BrowserStack. This is how the devices provided by BrowserStack can access your application under test.
{
"app_url": "bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3",
"custom_id": "SampleApp",
"shareable_id": "steve/SampleApp"
}
Next, you'll need to modify codecept.conf.js
to run the tests in BrowserStack. Ensure you store sensitive info in an .env
file and access using dotenv.
helpers: {
Appium: {
host: "hub-cloud.browserstack.com",
port: 4444,
user: process.env.BROWSERSTACK_USER,
key: process.env.BROWSERSTACK_KEY,
platform: "Android",
app: process.env.BROWSERSTACK_APP_URL,
desiredCapabilities: {
realMobile: "true",
device: "Samsung Galaxy S9",
os_version: "8.0",
networkLogs : "true",
}
}
},
The new properties needed are:
-
host
: your browserstack host url -
user
: your browserstack username -
key
: your browserstack accesskey -
app
: your uploaded app url -
desiredCapabilities
: choose your device + appium settings. More can be found here
With this set, you're all good to go. No changes are need to your individual test files. When you're ready, run tests as you normally would and you'll see each test run tracked in the BrowserStack dashboard.
Top comments (0)