BrowserStack App Automate enables you to test native and hybrid mobile applications using Appium automation framework. Its easy to run your Appium tests written in NodeJS on real Android and iOS devices on BrowserStack. This guide will help you get started with your first test.
username
and access key
. To obtain your access credentials, sign up for a free trial or purchase a plan..apk
or .aab
file) or an iOS app (.ipa
file).apk
or .ipa
file and are looking to simply try App Automate, you can download and test using our sample Android app or sample iOS app.
Upload your Android app (.apk
or .aab
file) or iOS app (.ipa
file) to BrowserStack servers using our REST API. Here is an example cURL
request to upload the app :
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file/Application-debug.apk"
A sample response for the above request is shown below:
{
"app_url":"bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"
}
Note the value of app_url
returned in the API response (bs://j3c874f21852b.....
in the above example).
This value will be used later to set the app
capability to specify application under test in your Appium test scripts.
cURL
command until you get the response back.In this step, you will learn how to configure your Appium test script using desired capabilities to test remotely on BrowserStack’s real device cloud. You will need to make the following changes in your NodeJS test script :
app
capability.
Use the app_url
value returned at the time of app upload (Step 2) to set this capability.device
capability. https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub
If you are using our Sample App, the sample test below will install the Sample App (Wikipedia App) on the device, search for ‘browserstack’ and asserts for the list of results. If you are using your own app, modify the code as per your test cases. Copy the code below into your editor, and run the test from the command-line interface.
var wd = require('wd');
var assert = require('assert');
var asserters = wd.asserters;
desiredCaps = {
'browserstack.user' : 'YOUR_USERNAME',
'browserstack.key' : 'YOUR_ACCESS_KEY',
'build' : 'Node Android',
'name': 'single_test',
'device' : 'Google Pixel 3',
'app' : '<app_url>',
'browserstack.debug' : true
};
driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub");
driver
.init(desiredCaps)
.then(function () {
return driver.waitForElementByAccessibilityId('Search Wikipedia', asserters.isDisplayed && asserters.isEnabled, 30000);
})
.then(function (searchElement) {
return searchElement.click();
})
.then(function () {
return driver.waitForElementById('org.wikipedia.alpha:id/search_src_text', asserters.isDisplayed && asserters.isEnabled, 30000);
})
.then(function (searchInput) {
return searchInput.sendKeys("BrowserStack");
})
.then(function () {
return driver.elementsByClassName('android.widget.TextView');
})
.then(function (search_results) {
assert(search_results.length > 0);
})
.fin(function() { return driver.quit(); })
.done();
If you are using our iOS Sample App, the sample test below will install the Sample App (BStackSample App) on the device, navigate to the Login screen, enters the login email and check whether the email is registered on WordPress. If you are using your own app, modify the code as per your test cases. Copy the code below into your editor, and run the test from the command-line interface.
var wd = require('wd');
var assert = require('assert');
var asserters = wd.asserters;
var sleep = require('sleep');
var Q = wd.Q;
desiredCaps = {
'browserstack.user' : 'YOUR_USERNAME',
'browserstack.key' : 'YOUR_ACCESS_KEY',
'build' : 'Node iOS',
'name': 'single_test',
'device' : 'iPhone 11 Pro',
'app' : '<app_url>',
'browserstack.debug' : true
};
driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub");
driver
.init(desiredCaps)
.then(function () {
return driver.waitForElementById('Text Button', asserters.isDisplayed && asserters.isEnabled, 30000);
})
.then(function (textButton) {
return textButton.click();
})
.then(function () {
return driver.waitForElementById('Text Input', asserters.isDisplayed && asserters.isEnabled, 30000);
})
.then(function (textInput) {
return textInput.sendKeys("hello@browserstack.com"+"\n");
})
.then(function () {
return driver.waitForElementById('Text Output', asserters.isDisplayed && asserters.isEnabled, 30000);
})
.then(function (textOutput) {
return textOutput.text().then(function(value) {
if (value === "hello@browserstack.com")
assert(true);
else
assert(false);
});
})
.fin(function() { return driver.quit(); })
.done();
You can access results of your test sessions on the App Automate dashboard as well as using our REST API. You can drill down into the details of a specific test session to view its execution details and debugging information such as video recording, network logs and device logs.
Contact our Support team for immediate help while we work on improving our docs.
Contact our Support team for immediate help while we work on improving our docs.