Home

Awesome

node-browserstack

A node.js JavaScript client for working with BrowserStack through its REST API (aka Javascript Testing API), Automate API, App Automate API, and Screenshots API.

Installation

npm install browserstack

Usage

var BrowserStack = require("browserstack");
var browserStackCredentials = {
	username: "foo",
	password: "p455w0rd!!1"
};

// REST API
var client = BrowserStack.createClient(browserStackCredentials);

client.getBrowsers(function(error, browsers) {
	console.log("The following browsers are available for testing");
	console.log(browsers);
});

// Automate API
var automateClient = BrowserStack.createAutomateClient(browserStackCredentials);

automateClient.getBrowsers(function(error, browsers) {
	console.log("The following browsers are available for automated testing");
	console.log(browsers);
});

// App Automate API
// Show the upload builds for mobile app automation
var appAutomateClient = BrowserStack.createAppAutomateClient(browserStackCredentials);

appAutomateClient.getBuilds(function(error, builds) {
	console.log("The following builds are available for app automated testing");
	console.log(builds);
});

// Screenshots API
var screenshotClient = BrowserStack.createScreenshotClient(browserStackCredentials);

screenshotClient.getBrowsers(function(error, browsers) {
	console.log("The following browsers are available for screenshots");
	console.log(browsers);
});

API

Objects

browser objects

A common pattern in the APIs is a "browser object" which is just a plain object with the following properties:

A browser object may only have one of browser or device set; which property is set will depend on os.

worker objects

Worker objects are extended browser objects which contain the following additional properties:

project objects

Project objects are plain objects which contain the following properties:

build objects

Build objects are plain objects which contain the following properties:

extended build objects

Extended build objects are build objects with the following additional properties:

session objects

Session objects are extended browser objects which contain the following additional properties:

screenshot job objects

Screenshot job objects are plain objects which contain the following properties:

screenshot state objects

Screenshot state objects are extended browser objects which contain the following additional properties:

REST API v4

Note: For earlier versions of the API, please see the wiki.

BrowserStack.createClient(settings)

Creates a new client instance.

client.getBrowsers(callback)

Gets the list of available browsers.

client.createWorker(settings, callback)

Creates a worker.

Note: A special value of "latest" is supported for browser_version, which will use the latest stable version.

client.getWorker(id, callback)

Gets the status of a worker.

client.changeUrl(id, options, callback)

Change the URL of a worker.

client.terminateWorker(id, callback)

Terminates an active worker.

client.getWorkers(callback)

Gets the status of all workers.

client.takeScreenshot(id, callback)

Take a screenshot at current state of worker.

client.getLatest(browser, callback)

Gets the latest version of a browser.

Note: Since mobile devices do not have version numbers, there is no latest version.

client.getLatest(callback)

Gets the latest version of all browsers.

client.getApiStatus(callback)

Automate API

BrowserStack.createAutomateClient(settings)

Creates a new client instance.

automateClient.getPlan(callback)

Gets information about your group's Automate plan, including the maximum number of parallel sessions allowed and the number of parallel sessions currently running.

automateClient.getBrowsers(callback)

Gets the list of available browsers.

automateClient.getProjects(callback)

Gets the list of projects.

automateClient.getProject(id, callback)

Gets information about a project.

automateClient.getBuilds([options,] callback)

Gets the list of builds.

automateClient.getSessions(buildId, [options,] callback)

Gets the list of sessions in a build.

automateClient.getSession(id, callback)

Gets the details for a session.

automateClient.updateSession(id, options, callback)

Updates the status of a session.

automateClient.deleteSession(id, callback)

Deletes a session.

App Automate API

BrowserStack.createAppAutomateClient(settings)

Creates a new client instance.

automateClient.getPlan(callback)

Gets information about your group's App Automate plan, including the maximum number of parallel sessions allowed and the number of parallel sessions currently running.

automateClient.getProjects(callback)

Gets the list of projects.

automateClient.getProject(id, callback)

Gets information about a project.

automateClient.getBuilds([options,] callback)

Gets the list of builds.

automateClient.getSessions(buildId, [options,] callback)

Gets the list of sessions in a build.

automateClient.getSession(id, callback)

Gets the details for a session.

automateClient.updateSession(id, options, callback)

Updates the status of a session.

automateClient.deleteSession(id, callback)

Deletes a session.

Screenshots API

BrowserStack.createScreenshotClient(settings)

Creates a new client instance.

screenshotClient.getBrowsers(callback)

Gets the list of available browsers.

screenshotClient.generateScreenshots(options, callback)

Creates a job to take screenshots.

screenshotClient.getJob(id, callback)

Gets details about the current status of a screenshot job.

Tests

To run the full test suite, you must have a BrowserStack account. Run npm test with the BROWSERSTACK_USERNAME and BROWSERSTACK_KEY environment variables set.

To run just the lint checks, run npm lint.

License

Copyright node-browserstack contributors. Released under the terms of the MIT license.