GithubHelp home page GithubHelp logo

saucelabs-connector's Introduction

saucelabs-connector

Helps connect the local machine to SauceLabs and start a remote browser.

Install

$ npm install saucelabs-connector

Usage

var SauceLabsConnector = require('saucelabs-connector').default;

// Use this online tool to generate a valid platform configuration: 
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
var browserInfo = {
    platform:    'Windows 10',
    browserName: 'chrome',
    version:     '45.0'
};

var pageUrl    = 'www.example.com';
var jobTimeout = 60; // in seconds
var jobOptions = {
    jobName: 'Sample tests',
    build:   'build-1234',
    tags:    ['tag1', 'tag2', 'tag3']
};

// See more information about options: https://github.com/bermi/sauce-connect-launcher/blob/master/README.md
var sauceConnectOptions = {
    verbose: false,
    vv:      false
};

var saucelabsConnector = new SauceLabsConnector('SAUCELABS_USERNAME', 'SAUCELABS_ACCESS_KEY', sauceConnectOptions);
var saucelabsBrowser   = null;

// Connects the local machine to SauceLabs
saucelabsConnector
    .connect()
    .then(function () {
        // Use the waitForFreeMachines method to ensure that the required number of machines is available.
        var machineCount    = 3;     // the required number of machines.
        var requestInterval = 30000; // the request delay in milliseconds.
        var maxAttemptCount = 5;     // the maximum number of attempts.
        
        return saucelabsConnector.waitForFreeMachines(machineCount, requestInterval, maxAttemptCount);
    })
    .then(function () {
        // Starts a remote browser on SauceLabs with the specified url.
        // jobOptions and jobTimeout are optional arguments.
        return saucelabsConnector.startBrowser(browserInfo, pageUrl, jobOptions, jobTimeout);
    })
    .then(function (browser) {
        saucelabsBrowser = browser;
        // Do some work with the browser
    })
    .then(function () {
        // Closes the browser
        return saucelabsConnector.stopBrowser(saucelabsBrowser);
    })
    .then(function () {
        return saucelabsConnector.disconnect();
    });

Additional Configuration

You can select the data center you want to connect to, by setting the environment variable SAUCE_API_HOST to the respective data center's host:

export SAUCE_API_HOST=saucelabs.com # for us-west-1, default
export SAUCE_API_HOST=eu-central-1.saucelabs.com # for eu-central-1

saucelabs-connector's People

Contributors

andreybelym avatar alexandermoskovkin avatar farfurix avatar kisrefod avatar kirovboris avatar yannikrudolph0108 avatar miherlosev avatar patrykkopycinski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.