Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d9b6ff5
Bump wdio version to 7.20.5 | Add wdio browserstack-service
avinash-bharti Aug 22, 2022
06df7e5
Add w3c capabilities
avinash-bharti Aug 22, 2022
d778bcb
Use browserstack-service for local binary invocation | Add W3C capabi…
avinash-bharti Aug 22, 2022
9a5e1e4
Add w3c capabilities
avinash-bharti Aug 22, 2022
0a80863
Add w3c capabilities for parllel tests
avinash-bharti Aug 22, 2022
c5e1e84
IOS | Bump wdio version | Add wdio browserstack-service
avinash-bharti Aug 22, 2022
8f102ee
IOS | Add w3c capabilities
avinash-bharti Aug 22, 2022
098bea4
IOS | use browserstack-service for local testing with w3c caps
avinash-bharti Aug 22, 2022
eeb0dd3
IOS | Add w3c caps for multiple tests
avinash-bharti Aug 22, 2022
f74c401
IOS | Add w3c caps for parallel tests
avinash-bharti Aug 22, 2022
ced3230
Update README with w3c and webdriverIO version
avinash-bharti Aug 22, 2022
77fcb84
Refactor code
avinash-bharti Aug 23, 2022
00a1ae8
Bump to latest appium client version
avinash-bharti Aug 23, 2022
5a182e4
Use standard build and test names
avinash-bharti Aug 24, 2022
1993c23
Use device configuration which supports sample ios app
avinash-bharti Aug 24, 2022
19414ba
Use local app file upload feature
avinash-bharti Oct 25, 2022
133f9c4
Use substring matching rather than exact matching of string
avinash-bharti Oct 25, 2022
ada94bd
remove app cap from caps, browserstack-service handling it
avinash-bharti Oct 31, 2022
b7202cd
remove session_name from caps, as browserstack-service will mark it a…
avinash-bharti Nov 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# webdriverio-appium-app-browserstack

This repository demonstrates how to run Appium tests using [WebdriverIO](http://webdriver.io/) on BrowserStack App Automate.

<div align="center">
Expand All @@ -8,11 +9,18 @@ This repository demonstrates how to run Appium tests using [WebdriverIO](http://

Code samples to get started with Appium tests for your Native App using WebdriverIO.

## Based on

These code samples are currently based on:

- **WebdriverIO:** `7.20.5`
- **Protocol:** `W3C`

## Setup

### Requirements

* Node.js 8.11.2+
- Node.js 8.11.2+
- If you don't have Node installed, download it from [here](https://nodejs.org/en/)

### Install the dependencies
Expand All @@ -38,12 +46,13 @@ npm i
Getting Started with Appium tests using WebdriverIO on BrowserStack couldn't be easier!

### Run first test:
- Test script is available in `run-first-test` directory under [Android examples](./android) or [iOS examples](./ios)
- Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/nodejs/webdriverio)

- Test script is available in `run-first-test` directory under [Android examples](./android) or [iOS examples](./ios)
- Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/nodejs/webdriverio)

### Speed up test execution with parallel testing :

- Test script is available in `run-parallel-test` directory under [Android examples](./android) or [iOS examples](./ios)
- Test script is available in `run-parallel-test` directory under [Android examples](./android) or [iOS examples](./ios)
- Follow the steps outlined in the documentation - [Get Started with parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/nodejs/webdriverio/parallelize-tests)

### Use Local testing for apps that access resources hosted in development or testing environments :
Expand All @@ -56,4 +65,3 @@ Getting Started with Appium tests using WebdriverIO on BrowserStack couldn't be
## Getting Help

If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).

18 changes: 11 additions & 7 deletions android/examples/run-first-test/first.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ exports.config = {
exclude: [],

capabilities: [{
project: "First Webdriverio Android Project",
build: 'Webdriverio Android',
name: 'first_test',
device: 'Google Pixel 3',
os_version: "9.0",
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.debug': true
platformName: "Android",
"appium:platformVersion": "9.0",
"appium:deviceName": 'Google Pixel 3',
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio Android Project",
"buildName" : "Webdriverio Android",
"sessionName" : "first_test",
"debug" : "true"
}
}],

logLevel: 'info',
Expand All @@ -25,6 +28,7 @@ exports.config = {
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [['browserstack']],

framework: 'mocha',
mochaOpts: {
Expand Down
54 changes: 17 additions & 37 deletions android/examples/run-local-test/local.conf.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
var browserstack = require('browserstack-local');

exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',

// Adding browserstackLocal to browserstack-service to initiate local binary
services: [
['browserstack', {
browserstackLocal: true
}]
],

updateJob: false,
specs: [
'./examples/run-local-test/specs/local_test.js'
],
exclude: [],

capabilities: [{
project: "First Webdriverio Android Project",
build: 'Webdriverio Android Local',
name: 'local_test',
device: 'Google Pixel 3',
os_version: "9.0",
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.local': true,
'browserstack.debug': true
platformName: "Android",
"appium:platformVersion": "9.0",
"appium:deviceName": 'Google Pixel 3',
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio Android Project",
"buildName" : "Webdriverio Android Local",
"sessionName" : "local_test",
"debug" : "true"
}
}],

logLevel: 'info',
Expand All @@ -33,32 +40,5 @@ exports.config = {
mochaOpts: {
ui: 'bdd',
timeout: 20000
},

// Code to start browserstack local before start of test
onPrepare: (config, capabilities) => {
console.log("Connecting local");
return new Promise( (resolve, reject) => {
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config.key }, (error) => {
if (error) return reject(error);
console.log('Connected. Now testing...');

resolve();
});
});
},

// Code to stop browserstack local after end of test
onComplete: (capabilties, specs) => {
console.log("Closing local tunnel");
return new Promise( (resolve, reject) => {
exports.bs_local.stop( (error) => {
if (error) return reject(error);
console.log("Stopped BrowserStackLocal");

resolve();
});
});
}
};
18 changes: 11 additions & 7 deletions android/examples/run-multiple-test/multiple.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ exports.config = {
exclude: [],

capabilities: [{
project: "First Webdriverio Android Project",
build: 'Webdriverio Android Multiple',
name: 'multiple_test',
device: 'Google Pixel 3',
os_version: "9.0",
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.debug': true
platformName: "Android",
"appium:platformVersion": "9.0",
"appium:deviceName": 'Google Pixel 3',
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio Android Project",
"buildName" : "Webdriverio Android Multiple",
"sessionName" : "multiple_test",
"debug" : "true"
}
}],

logLevel: 'info',
Expand All @@ -25,6 +28,7 @@ exports.config = {
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [['browserstack']],

framework: 'mocha',
mochaOpts: {
Expand Down
33 changes: 21 additions & 12 deletions android/examples/run-parallel-test/parallel.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,27 @@ exports.config = {

maxInstances: 10,
commonCapabilities: {
project: "First Webdriverio Android Project",
build: 'Webdriverio Android Parallel',
name: 'parallel_test',
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.debug': true
platformName: "Android",
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio Android Project",
"buildName" : "Webdriverio Android Parallel",
"debug" : "true"
}
},

capabilities: [{
device: 'Google Pixel 3',
os_version: "9.0"
"appium:deviceName": 'Google Pixel 3',
"appium:platformVersion": "9.0",
'bstack:options' : {
"sessionName" : "parallel_test1"
}
}, {
device: 'Samsung Galaxy S10e',
os_version: "9.0"
"appium:deviceName": 'Samsung Galaxy S10e',
"appium:platformVersion": "9.0",
'bstack:options' : {
"sessionName" : "parallel_test2"
}
}],

logLevel: 'info',
Expand All @@ -32,6 +40,7 @@ exports.config = {
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [['browserstack']],

framework: 'mocha',
mochaOpts: {
Expand All @@ -41,6 +50,6 @@ exports.config = {
};

// Code to support common capabilities
exports.config.capabilities.forEach(function(caps){
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
});
var common_caps = exports.config.commonCapabilities
var caps = exports.config.capabilities
for (var i in caps) caps[i] = { ...caps[i], ...common_caps };
14 changes: 8 additions & 6 deletions android/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "webdriverio-appium-app-browserstack",
"version": "0.1.0",
"readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
"description": "Selenium examples for WebdriverIO and BrowserStack App Automate",
"readme": "WebdriverIO Integration with [BrowserStack](https://www.browserstack.com)",
"description": "Appium examples for WebdriverIO and BrowserStack App Automate",
"scripts": {
"test": "npm run first && npm run local && npm run parallel",
"first": "./node_modules/.bin/wdio examples/run-first-test/first.conf.js",
Expand All @@ -25,9 +25,11 @@
},
"homepage": "https://github.com/browserstack/webdriverio-appium-app-browserstack#readme",
"dependencies": {
"@wdio/cli": "^5.20.1",
"@wdio/local-runner": "^5.20.1",
"@wdio/mocha-framework": "^5.18.7",
"browserstack-local": "^1.4.5"
"@wdio/cli": "^7.20.5"
},
"devDependencies": {
"@wdio/browserstack-service": "^7.20.5",
"@wdio/local-runner": "^7.20.5",
"@wdio/mocha-framework": "^7.20.3"
}
}
18 changes: 11 additions & 7 deletions ios/examples/run-first-test/first.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ exports.config = {
exclude: [],

capabilities: [{
project: "First Webdriverio iOS Project",
build: 'Webdriverio iOS',
name: 'single_test',
device: 'iPhone 11 Pro',
os_version: "13",
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.debug': true
platformName: "ios",
"appium:platformVersion": "13",
"appium:deviceName": 'iPhone 11 Pro',
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio iOS Project",
"buildName" : "Webdriverio iOS",
"sessionName" : "single_test",
"debug" : "true"
}
}],

logLevel: 'info',
Expand All @@ -25,6 +28,7 @@ exports.config = {
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [['browserstack']],

framework: 'mocha',
mochaOpts: {
Expand Down
54 changes: 17 additions & 37 deletions ios/examples/run-local-test/local.conf.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
var browserstack = require('browserstack-local');

exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',

// Adding browserstackLocal to browserstack-service to initiate local binary
services: [
['browserstack', {
browserstackLocal: true
}]
],

updateJob: false,
specs: [
'./examples/run-local-test/specs/local_test.js'
],
exclude: [],

capabilities: [{
project: "First Webdriverio iOS Project",
build: 'Webdriverio iOS Local',
name: 'local_test',
device: 'iPhone 11 Pro',
os_version: "13",
app: process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'browserstack.local': true,
'browserstack.debug': true
platformName: "ios",
"appium:platformVersion": "13",
"appium:deviceName": 'iPhone 11 Pro',
"appium:app": process.env.BROWSERSTACK_APP_ID || 'bs://<hashed app-id>',
'bstack:options' : {
"projectName" : "First Webdriverio iOS Project",
"buildName" : "Webdriverio iOS Local",
"sessionName" : "local_test",
"debug" : "true"
}
}],

logLevel: 'info',
Expand All @@ -34,31 +41,4 @@ exports.config = {
ui: 'bdd',
timeout: 30000
},

// Code to start browserstack local before start of test
onPrepare: (config, capabilities) => {
console.log("Connecting local");
return new Promise( (resolve, reject) => {
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config.key }, (error) => {
if (error) return reject(error);
console.log('Connected. Now testing...');

resolve();
});
});
},

// Code to stop browserstack local after end of test
onComplete: (capabilties, specs) => {
console.log("Closing local tunnel");
return new Promise( (resolve, reject) => {
exports.bs_local.stop( (error) => {
if (error) return reject(error);
console.log("Stopped BrowserStackLocal");

resolve();
});
});
}
};
Loading