1. browserstack-automate
Run selenium tests on BrowserStack using our node.js integration.
browserstack-automate
Package: browserstack-automate
Created by: browserstack
Last modified: Mon, 13 Jun 2022 05:11:26 GMT
Version: 1.0.2
License: ISC
Downloads: 196
Repository: https://github.com/browserstack/browserstack-integration-nodejs

Install

npm install browserstack-automate
yarn add browserstack-automate

BrowserStack-Integration

Patches for Selenium scripts and test suites to run on BrowserStack when RUN_ON_BSTACK=true is set in environment.
Currently supports Nightwatch.js.

BrowserStack Logo

NodeJS

Running the test

Installation

npm install browserstack-automate

Node script

  • To run locally, run npm link && cd examples/simple_sample/ && npm install && npm link browserstack-automate
  • To run on BrowserStack, run RUN_ON_BSTACK=true node sample.js

Nightwatch test

  • Add the following line in your configuration file:
    require('browserstack-automate').Nightwatch();

  • To run locally, run npm link && cd examples/nightwatch/ && npm install && npm link browserstack-automate

  • To run on BrowserStack, run RUN_ON_BSTACK=true ./node_modules/.bin/nightwatch -c conf.js

Configuring Tests

The following environment variables are supported,

RUN_ON_BSTACK - Boolean. To run your tests on BrowserStack
BSTACK_LOCAL - Boolean. Whether to start/stop BrowserStackLocal for your tests

BROWSERSTACK_USERNAME - your BrowserStack username
BROWSERSTACK_ACCESS_KEY - your BrowserStack accesskey

Setup

  • Clone the repo

  • Install dependencies npm install

  • Export the environment variables for the Username and Access Key of your BrowserStack account

    export BROWSERSTACK_USERNAME=<browserstack-username>
    export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
    

To run tests

npm test

To integrate with your nightwatch framework

  • Add the following to conf.js file.
require('browserstack-automate').Nightwatch();

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code