How to use browserstack - 10 common examples

To help you get started, we’ve selected a few browserstack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-js / test / browserstack.js View on Github external
browser_version: '7.0',
    os: 'OS X',
    os_version: 'Mavericks'
  },
  firefox: {
    browser: 'Firefox',
    browser_version: '26.0',
    os: 'Windows',
    os_Version: '8'
  }
};


// Input capabilities
var capabilities = browsers[process.argv[2]];
capabilities['browserstack.user'] = 'conrad10';
capabilities['browserstack.key'] = process.env.BROWSERSTACK_KEY || process.exit(console.log('no BROWSERSTACK_KEY set'));

var driver = new webdriver.Builder().
usingServer('http://hub.browserstack.com/wd/hub').
withCapabilities(capabilities).
build();

driver.get('http://jelzo.com:6123/bugsnag/');
var tries = 0;

function check() {
  driver.getTitle().then(function(title) {
    if (title) {
      console.log(title);
      driver.quit();
    } else if (tries < 10) {
github OpenDataRepository / data-publisher / test-browser / features / support / hooks.js View on Github external
this.Before(function (scenario, callback) {
    world = this;
    var task_id = parseInt(process.env.TASK_ID || 0);
    var caps = config.capabilities[task_id];
    caps['browserstack.user'] = username;
    caps['browserstack.key'] = accessKey;

    // Make the broswer name available to scripts (easily)
    globals.browser_name = caps['browserName'];

    if(caps["browserstack.local"]){
      // Code to start browserstack local before start of test and stop browserstack local after end of test
      bs_local = new browserstack.Local();
      bs_local.start({'key': accessKey }, function(error) {
        if (error) return console.log(error.red);

        world.driver = createBrowserStackSession(config, caps);
        callback();
      });
    }
    else {
      world.driver = createBrowserStackSession(config, caps);
      callback();
    }
  });
github ScottLogic / finput / test / capabilities.js View on Github external
import {Capability, Browser} from 'selenium-webdriver';

const capabilities = {
  [Capability.PLATFORM]: 'WINDOWS',
  [Capability.BROWSER_NAME]: Browser.CHROME,
  [Capability.VERSION]: 73,
};

// browserstack specific capabilities - https://www.browserstack.com/automate/capabilities
if (process.env.CI) {
  capabilities['browserstack.local'] = true;
  capabilities['browserstack.localIdentifier'] = process.env.BROWSERSTACK_LOCAL_IDENTIFIER || process.env.TRAVIS_JOB_NUMBER;
  capabilities['browserstack.networkLogs'] = true;
  capabilities.os = 'WINDOWS';
  capabilities.os_version = '10';
  capabilities.browser = Browser.CHROME;
  capabilities.browser_version = '73';
}

export default capabilities;
github ScottLogic / finput / test / capabilities.js View on Github external
import {Capability, Browser} from 'selenium-webdriver';

const capabilities = {
  [Capability.PLATFORM]: 'WINDOWS',
  [Capability.BROWSER_NAME]: Browser.CHROME,
  [Capability.VERSION]: 73,
};

// browserstack specific capabilities - https://www.browserstack.com/automate/capabilities
if (process.env.CI) {
  capabilities['browserstack.local'] = true;
  capabilities['browserstack.localIdentifier'] = process.env.BROWSERSTACK_LOCAL_IDENTIFIER || process.env.TRAVIS_JOB_NUMBER;
  capabilities['browserstack.networkLogs'] = true;
  capabilities.os = 'WINDOWS';
  capabilities.os_version = '10';
  capabilities.browser = Browser.CHROME;
  capabilities.browser_version = '73';
}

export default capabilities;
github ScottLogic / finput / test / capabilities.js View on Github external
import {Capability, Browser} from 'selenium-webdriver';

const capabilities = {
  [Capability.PLATFORM]: 'WINDOWS',
  [Capability.BROWSER_NAME]: Browser.CHROME,
  [Capability.VERSION]: 73,
};

// browserstack specific capabilities - https://www.browserstack.com/automate/capabilities
if (process.env.CI) {
  capabilities['browserstack.local'] = true;
  capabilities['browserstack.localIdentifier'] = process.env.BROWSERSTACK_LOCAL_IDENTIFIER || process.env.TRAVIS_JOB_NUMBER;
  capabilities['browserstack.networkLogs'] = true;
  capabilities.os = 'WINDOWS';
  capabilities.os_version = '10';
  capabilities.browser = Browser.CHROME;
  capabilities.browser_version = '73';
}

export default capabilities;
github dbrans / browserstack-cli / bin / cli.js View on Github external
if(cmd.user) {
    // get auth from commandline
    auth = parseUser(cmd.user);
  } else if(config.username && config.password) {
    // get auth info from config
    auth = {
      username: config.username,
      password: config.password
    };
  } else {
    console.error('Authentication required. Use option "--user" or put a "username" and "password" in ' + CONFIG_FILE);
    process.exit(1);
  }

  return browserstack.createClient(extend(settings, auth));
}
github mdittmer / web-apis / lib / remote / selenium / browserstack.es6.js View on Github external
function buildConfig(inputConfig) {
  let config = {};

  // Generally suffice with default Selenium version, except for some versions
  // of firefox, based on advice from BrowserStack Automate console and a bunch
  // of trial and error.
  if (inputConfig.browserName && inputConfig.browserName.toLowerCase() === 'firefox') {
    const version = parseInt(inputConfig.browser_version.split('.')[0], 10);
    if (version >= 48 && version <= 57)
      config['browserstack.selenium_version'] = '3.4.0';
  }

  Object.assign(config, inputConfig, base);
  console.log('Build with', config, url);
  return new webdriver.Builder().withCapabilities(config).usingServer(url)
    .build();
}
github browserstack / cucumber-js-browserstack / features / support / hooks.js View on Github external
this.Before(function (scenario, callback) {
    var world = this;
    var task_id = parseInt(process.env.TASK_ID || 0);
    var caps = config.capabilities[task_id];
    caps['browserstack.user'] = username;
    caps['browserstack.key'] = accessKey;

    if(caps["browserstack.local"]){
      // Code to start browserstack local before start of test and stop browserstack local after end of test
      bs_local = new browserstack.Local();
      bs_local.start({'key': accessKey }, function(error) {
        if (error) return console.log(error.red);

        world.driver = createBrowserStackSession(config, caps);
        callback();
      });
    }
    else {
      world.driver = createBrowserStackSession(config, caps);
      callback();
    }
  });
github ryanseddon / bunyip / lib / helpers.js View on Github external
var browserstack = require("browserstack"),
	config = require("./config");

var workers = [],
	timeout = config.browserstack.timeout || 480, // 8 minutes
	client = browserstack.createClient(config.browserstack),
	osMap = {};

var	loadBrowsers = function(browsers) {
		browsers.forEach(function(browser, idx){
			client.createWorker(browser, function(err, worker){
				if(err) {
					console.log(err);
					console.log("Whoops! BrowserStack failed to create a worker: %s", err);
				} else {
					console.log("  BrowserStack "+ (browser.browser || browser.device) + " " + browser.version +" worker launched: %s", worker.id);
					workers.push(worker.id);
				}
			});
		});
	},
	availableBrowsers = function(cb) {
github browserstack / cucumber-js-browserstack / features / support / hooks.js View on Github external
this.Before(function (scenario, callback) {
    var world = this;
    var task_id = parseInt(process.env.TASK_ID || 0);
    var caps = config.capabilities[task_id];
    caps['browserstack.user'] = username;
    caps['browserstack.key'] = accessKey;

    if(caps["browserstack.local"]){
      // Code to start browserstack local before start of test and stop browserstack local after end of test
      bs_local = new browserstack.Local();
      bs_local.start({'key': accessKey }, function(error) {
        if (error) return console.log(error.red);

        world.driver = createBrowserStackSession(config, caps);
        callback();
      });
    }
    else {
      world.driver = createBrowserStackSession(config, caps);
      callback();
    }
  });