diff --git a/README.md b/README.md index 99743df..21684f5 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ This repository demonstrates how to run Appium NodeJS tests on BrowserStack App Automate. +## Based on + +These code samples are currently based on: + +- **Wd:** `1.14.0` +- **Protocol:** `W3C` ## Setup ### Requirements @@ -84,7 +90,7 @@ Open `BrowserStackSampleLocal.js` file in `Android` or in `ios` folder - Set the device and OS version -- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Javascript binding for BrowserStack Local. +- Ensure that `local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Javascript binding for BrowserStack Local. - If you have uploaded your own app update the test case diff --git a/android/BrowserStackSample.js b/android/BrowserStackSample.js index 2ca481b..da88b1b 100644 --- a/android/BrowserStackSample.js +++ b/android/BrowserStackSample.js @@ -3,26 +3,29 @@ let assert = require('assert'); let asserters = wd.asserters; desiredCaps = { - // Set your BrowserStack access credentials - 'browserstack.user' : 'YOUR_USERNAME', - 'browserstack.key' : 'YOUR_ACCESS_KEY', - - // Set URL of the application under test - 'app' : 'bs://', + "forceW3C": true, // Specify device and os_version for testing - 'device' : 'Google Pixel 3', - 'os_version' : '9.0', + "platformName": "Android", + "appium:platformVersion": "9.0", + "appium:deviceName": 'Google Pixel 3', + // Set URL of the application under test + "appium:app": 'bs://', // Set other BrowserStack capabilities - 'project' : 'First NodeJS project', - 'build' : 'Node Android', - 'name': 'first_test' + 'bstack:options' : { + "projectName" : "First NodeJS Android Project", + "buildName" : "browserstack-build-1", + "sessionName" : "BStack first_test", + "debug" : "true", + "userName" : "YOUR_USERNAME", + "accessKey" : "YOUR_ACCESS_KEY" + } }; // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above -driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub"); +driver = wd.promiseRemote("http://hub.browserstack.com/wd/hub"); // Test case for the BrowserStack sample Android app. // If you have uploaded your app, update the test case here. diff --git a/android/BrowserStackSampleLocal.js b/android/BrowserStackSampleLocal.js index 9c17f34..d41ccf5 100644 --- a/android/BrowserStackSampleLocal.js +++ b/android/BrowserStackSampleLocal.js @@ -5,28 +5,29 @@ let Q = wd.Q; let browserstack = require('browserstack-local'); // Set your BrowserStack access credentials -let userName = 'YOUR_USERNAME' +let userName = "YOUR_USERNAME" let accessKey = "YOUR_ACCESS_KEY" desiredCaps = { - 'browserstack.user' : userName, - 'browserstack.key' : accessKey, + "forceW3C": true, - // Set URL of the application under test - 'app' : 'bs://', + // Specify device and os_version for testing + "platformName": "Android", + "appium:platformVersion": "9.0", + "appium:deviceName": 'Google Pixel 3', - // Specify device and os_version for testing - 'device' : 'Google Pixel 3', - 'os_version' : '9.0', - - //Set browserstack.local capability as true - 'browserstack.local' : true, - - // Set other BrowserStack capabilities - 'project' : 'First NodeJS project', - 'build' : 'Node Android Local', - 'name': 'local_test', - 'browserstack.debug' : true, + // Set URL of the application under test + "appium:app": 'bs://', + // Set other BrowserStack capabilities + 'bstack:options' : { + "projectName" : "First NodeJS Android Project", + "buildName" : "browserstack-build-1", + "sessionName" : "BStack local_test", + "debug" : "true", + "local" : "true", + "userName" : userName, + "accessKey" : accessKey + } }; let promise = new Promise(function(resolve, reject) { @@ -42,7 +43,7 @@ let promise = new Promise(function(resolve, reject) { promise.then(function() { // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above - driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub"); + driver = wd.promiseRemote("http://hub.browserstack.com/wd/hub"); // Test case for the BrowserStack sample Android Local app. // If you have uploaded your app, update the test case here. diff --git a/ios/BrowserStackSample.js b/ios/BrowserStackSample.js index e0958ea..6ae4d01 100644 --- a/ios/BrowserStackSample.js +++ b/ios/BrowserStackSample.js @@ -4,26 +4,29 @@ let asserters = wd.asserters; let Q = wd.Q; desiredCaps = { - // Set your BrowserStack access credentials - 'browserstack.user' : 'YOUR_USERNAME', - 'browserstack.key' : 'YOUR_ACCESS_KEY', + "forceW3C": true, - // Set URL of the application under test - 'app' : 'bs://', - - // Specify device and os_version for testing - 'device' : 'iPhone 11 Pro', - 'os_version' : '13', + // Specify device and os_version for testing + "platformName": "ios", + "appium:platformVersion": "13", + "appium:deviceName": 'iPhone 11 Pro', - // Set other BrowserStack capabilities - 'project' : 'First NodeJS project', - 'build' : 'Node iOS', - 'name': 'first_test' + // Set URL of the application under test + "appium:app": 'bs://', + // Set other BrowserStack capabilities + 'bstack:options' : { + "projectName" : "First NodeJS iOS Project", + "buildName" : "browserstack-build-1", + "sessionName" : "BStack first_test", + "debug" : "true", + "userName" : "YOUR_USERNAME", + "accessKey" : "YOUR_ACCESS_KEY" + } }; // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above -driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub"); +driver = wd.promiseRemote("http://hub.browserstack.com/wd/hub"); // Test case for the BrowserStack sample iOS app. // If you have uploaded your app, update the test case here. diff --git a/ios/BrowserStackSampleLocal.js b/ios/BrowserStackSampleLocal.js index 928ad84..ccf75bf 100644 --- a/ios/BrowserStackSampleLocal.js +++ b/ios/BrowserStackSampleLocal.js @@ -15,24 +15,25 @@ let userName = 'YOUR_USERNAME' let accessKey = "YOUR_ACCESS_KEY" desiredCaps = { - 'browserstack.user' : userName, - 'browserstack.key' : accessKey, - - // Set URL of the application under test - 'app' : 'bs://', - - // Specify device and os_version for testingg - 'device' : 'iPhone 11 Pro', - 'os_version' : '13', - - //Set browserstack.local capability as true - 'browserstack.local' : true, - + "forceW3C": true, + + // Specify device and os_version for testing + "platformName": "ios", + "appium:platformVersion": "12", + "appium:deviceName": 'iPhone XS', + + // Set URL of the application under test + "appium:app": 'bs://', // Set other BrowserStack capabilities - 'project' : 'First NodeJS project', - 'build' : 'Node iOS Local', - 'name': 'local_test', - 'browserstack.debug' : true, + 'bstack:options' : { + "projectName" : "First NodeJS iOS Project", + "buildName" : "browserstack-build-1", + "sessionName" : "BStack local_test", + "debug" : "true", + "local" : "true", + "userName" : userName, + "accessKey" : accessKey + } }; let promise = new Promise(function(resolve, reject) { @@ -48,7 +49,7 @@ let promise = new Promise(function(resolve, reject) { promise.then(function() { // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above - driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub"); + driver = wd.promiseRemote("http://hub.browserstack.com/wd/hub"); // Test case for the BrowserStack sample iOS Local app. // If you have uploaded your app, update the test case here. diff --git a/package.json b/package.json index f099689..eb9f5e6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appium-app-browserstack", "version": "0.1.0", "readme": "NodeJS Integration with [BrowserStack](https://www.browserstack.com)", - "description": "Appium iOS examples for NodeJS and BrowserStack App Automate", + "description": "Appium iOS and Android examples for NodeJS and BrowserStack App Automate", "repository": { "type": "git", "url": "git+https://github.com/browserstack/node-appium-app-browserstack.git" @@ -17,9 +17,9 @@ }, "homepage": "https://github.com/browserstack/node-appium-app-browserstack#readme", "dependencies": { - "browserstack-local": "^1.0.2", - "wd": "^1.13.0", - "chai": "^4.2.0", + "browserstack-local": "^1.1.1", + "wd": "^1.14.0", + "chai": "^4.3.6", "chai-as-promised": "7.1.1" }, "engines": {