Skip to main content

Integrate your test

App Automate enables you to test native and hybrid mobile applications using the Appium automation framework. You can use BrowserStack to run your Appium tests written using Nightwatch on real Android and iOS devices.

Nightwatch is a NodeJS-based automation framework that supports both web and mobile app testing. You can integrate BrowserStack App Automate in your Nightwatch test project by following these steps:

Prerequisites

  • A BrowserStack username and access_key. If you haven’t created an account yet, sign up for a free trial or purchase a paid plan. After signup, you can get your access credentials from Account Settings.
  • Node.js 14 or higher installed on your system. You can download the updated Node version from nodejs.org.
  • .apk or .aab file of your Android app, or .ipa file of your iOS app.
  • Basic Nightwatch project with relevant tests written for your mobile app. No additional requirements are needed to be set up for testing mobile apps on BrowserStack. You can learn more about this from the Nightwatch user guide.
Note: If you do not have an .apk or .ipa file and want to try App Automate, you can download and test using our sample Android app or sample iOS app.

Integration steps

Add App Automate specific environments to Nightwatch config

Add Browserstack, Android, and iOS environments and capabilities in the nightwatch.conf.js file.


    test_settings:{
    ...
    browserstack: {
      selenium: {
        host: 'hub.browserstack.com',
        port: 443
      },
      desiredCapabilities: {
       'bstack:options': {
          userName: '',
          accessKey: '',
          appiumVersion: '2.0.0'
        }
      },
      disable_error_log: false,
      webdriver: {
        timeout_options: {
          timeout: 60000,
          retry_attempts: 3
        },
        keep_alive: true,
        start_process: false
      }
    },
    'browserstack.android': {
      extends: 'browserstack',
      'desiredCapabilities': {
        browserName: null,
        'appium:options': {
          automationName: 'UiAutomator2',
          app: 'wikipedia-sample-app',// custom-id of the uploaded app
          appPackage: 'org.wikipedia',
          appActivity: 'org.wikipedia.main.MainActivity',
          appWaitActivity: 'org.wikipedia.onboarding.InitialOnboardingActivity',
          platformVersion: '11.0',
          deviceName: 'Google Pixel 5'
        },
        appUploadUrl: 'https://raw.githubusercontent.com/priyansh3133/wikipedia/main/wikipedia.apk',// URL of the app to be uploaded to BrowserStack before starting the test
        // appUploadPath: '/path/to/app_name.apk' // if the app needs to be uploaded to BrowserStack from a local system
      }
    },
    'browserstack.ios': {
      extends: 'browserstack',
      'desiredCapabilities': {
        browserName: null,
        platformName: 'ios',
        'appium:options': {
          automationName: 'XCUITest',
          app: 'BStackSampleApp',
          platformVersion: '16',
          deviceName: 'iPhone 14'
        },
        appUploadUrl: 'https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa',
        // appUploadPath: '/path/to/app_name.ipa'
      }
    ...
  }

Replace the config variables as per the requirements

Edit the following variables in the nightwatch.conf.js file with the values corresponding to your app:

Variables Description
BrowserStack username Your BrowserStack username.
BrowserStack key Your BrowserStack access key.
app Custom ID or BrowserStack URL (starts with bs://) of your app. Can also be used to set a custom id while uploading an app.
appPackage The package name of your app.
appActivity The main activity or screen of the app.
appWaitActivity A screen which loads initially instead of the main activity page (e.g. onboarding activity).
deviceName Name of the device in which you want to test. See a list of deviceName/PlatformName combinations available on BrowserStack.
platformVersion The Android or iOS version.
appUploadUrl Public URL of the app under test to upload to BrowserStack before testing.
appUploadPath Local path of the app under test to upload to BrowserStack before testing.

Run the Nightwatch tests

Run the test using the following command:

  npx nightwatch <path to tests> --env browserstack.android
  npx nightwatch <path to tests> --env browserstack.ios

View test execution results

You can access the test execution results and debugging information such as video recordings, network logs, and device logs on App Automate dashboard or using our REST APIs.

Need some help?

If you have any queries, please get in touch with us.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy