How to use wd - 10 common examples

To help you get started, we’ve selected a few wd 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 appium / appium / test / helpers / driverblock.js View on Github external
_before(function(done) {
    if (onSauce && this.currentTest) {
      caps.name = this.currentTest.parent.title + " " + this.currentTest.title;
    }

    driverHolder.driver = wd.promiseChainRemote(host, port);

    if (process.env.VERBOSE) {
      driverHolder.driver.on('status', function(info) {
        console.log(info);
      });
      driverHolder.driver.on('command', function(meth, path, data) {
        console.log(' > ' + meth, path, data || '');
      });
    }

    driverHolder.driver
      .init(caps)
      .then(
        // ok
        function(sessionId) {
          driverHolder.sessionId = sessionId;
github gr2m / appcache-nanny / bin / test-browser.js View on Github external
tunnelIdentifier: tunnelId,
  name: tmp[1] + ' - ' + tunnelId,
  // timeouts
  // tunnelTimeout: 30 * 60 * 1000,
  // 'max-duration': 60 * 45,
  // 'command-timeout': 599,
  // 'idle-timeout': 599
};



chai.use(chaiAsPromised);
chai.should();

// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

devServer.start(function() {
  if (client.runner === 'saucelabs') {
    startSauceConnect(startTest);
  } else {
    startSelenium(startTest);
  }
});

function startTest(browser, subProcess) {
  // optional extra logging
  // browser.on('status', function(info) {
  //   console.log(info.cyan);
  // });
  browser.on('command', function(eventType, command, response) {
    if (eventType === 'CALL') {
github wikipathways / pvjs / test / e2e / wikipathways.org.js View on Github external
var wd = require('wd')
  , imageDiff = require('image-diff')
  ;
require('colors');
var _ = require("lodash");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

// checking sauce credential
if(!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY){
    console.warn(
        '\nPlease configure your sauce credential:\n\n' +
        'export SAUCE_USERNAME=\n' +
        'export SAUCE_ACCESS_KEY=\n\n'
    );
    throw new Error("Missing sauce credentials");
}

// http configuration, not needed for simple runs
wd.configureHttp( {
    timeout: 60000,
    retryDelay: 15000,
    retries: 5
github springernature / shunter / bin / test-client.js View on Github external
var errors;
		var length;
		var browserName;
		var browserVersion;
		var sessionName;
		var driver;

		count = 0;
		errors = 0;
		length = urls.length;
		browserName = browser.browserName;
		browserVersion = browser.version;
		sessionName = browserName + ' ' + browserVersion;
		browser.name = sessionName;

		driver = wd.promiseRemote('ondemand.saucelabs.com', 80, saucelabsUser, saucelabsKey);
		driver.init(browser)
			.then(iterateTests)
			.fail(function () {
				console.log('Browser ' + sessionName + ' was not available');

				// SauceLabs' shitty API returns browsers that it doesn't support.
				// This hack retries progressively later versions of those browsers
				// until we find one that works or there are no more versions.
				var targetBrowser = {
					browserName: browserName,
					version: Math.floor(parseFloat(browserVersion) + 1)
				};

				saucelabs.getWebDriverBrowsers(retryTests.bind(null, targetBrowser));
			});
github wordpress-mobile / gutenberg-mobile / __device-tests__ / helpers / utils.js View on Github external
const setupDriver = async () => {
	const branch = process.env.CIRCLE_BRANCH || '';
	const safeBranchName = branch.replace( /\//g, '-' );
	if ( isLocalEnvironment() ) {
		try {
			appiumProcess = await AppiumLocal.start( localAppiumPort );
		} catch ( err ) {
			// Ignore error here, Appium is probably already running (Appium desktop has its own server for instance)
			// eslint-disable-next-line no-console
			console.log( 'Could not start Appium server', err.toString() );
		}
	}

	const serverConfig = isLocalEnvironment() ? serverConfigs.local : serverConfigs.sauce;
	const driver = wd.promiseChainRemote( serverConfig );

	let desiredCaps;
	if ( isAndroid() ) {
		desiredCaps = _.clone( android8 );
		if ( isLocalEnvironment() ) {
			desiredCaps.app = path.resolve( localAndroidAppPath );
			try {
				const androidVersion = childProcess
					.execSync( 'adb shell getprop ro.build.version.release' )
					.toString()
					.replace( /^\s+|\s+$/g, '' );
				delete desiredCaps.platformVersion;
				desiredCaps.deviceName = 'Android Emulator';
				// eslint-disable-next-line no-console
				console.log( 'Detected Android device running Android %s', androidVersion );
			} catch ( error ) {
github zs-zs / grunt-selenium-standalone / test / createClient.js View on Github external
var createClient = function createClient() {
	var res = wd.promiseChainRemote('localhost', process.env.LOCAL_SELENIUM_PORT || 4444)
		.init(automatedBrowsers.phantomjs.driver.config)
		.setWindowSize(1000, 1000) // do something
        .quit();
	return res;
};
github kerrishotts / Mastering-PhoneGap-Code-Package / logology-v06 / test-ui / helpers / util.js View on Github external
.then(() => {
                                 let action = new wd.TouchAction(driver);
                                 action = action.tap({x, y});
                                 if (profile.platformName === "iOS") {
                                     action = action.release();  // Android doesn't like this much
                                 }
                                 action = action.wait({ms:1000});
                                 return action.perform();
                             })
                             .then(switchToWebViewContext);
github Strider-CD / strider / test / runner.js View on Github external
var async = require('async');
var wd = require('wd');
var remote = JSON.parse(process.env.WEBDRIVER_REMOTE || '{"hostname":"localhost", "port":9515}');
var browsers = JSON.parse(process.env.BROWSERS || '[{"browserName":"chrome"}]' );
var strider = require('./strider');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

describe('Strider', function () {
  this.timeout(20000);

  // TESTS
  var tests = (
    process.env.TEST_SUITE ?
    [ './integration/'+process.env.TEST_SUITE+'.js' ] :
    [ './integration/build_page_test.js'
    , './integration/login_test.js'
    , './integration/global_admin_test.js'
    //, './integration/github_test.js'
    , './integration/branch_management_test.js'
  ]);

  wd.addPromiseChainMethod('rel', function (url, cb) {
github Strider-CD / strider / test / runner.js View on Github external
describe('Strider', function () {
  this.timeout(20000);

  // TESTS
  var tests = (
    process.env.TEST_SUITE ?
    [ './integration/'+process.env.TEST_SUITE+'.js' ] :
    [ './integration/build_page_test.js'
    , './integration/login_test.js'
    , './integration/global_admin_test.js'
    //, './integration/github_test.js'
    , './integration/branch_management_test.js'
  ]);

  wd.addPromiseChainMethod('rel', function (url, cb) {
    return this.get('http://localhost:4000' + url, cb);
  });

  var runTests = function (conn, doneBrowser) {
    var commands = [];

    async.each(tests, function (suite, cb) {
      var browser = wd.promiseChainRemote(remote);
      browser.on('status', function (info) {
        console.log(info);
      });
      browser.on('command', function (meth, path, data) {
        if (meth && path && data) commands.push([' command > ' + meth, path, JSON.stringify(data || '')].join(' '));
      });
      browser.on('error', function (info) {
        console.log(info);
github ustwo / ustwo.com-frontend / test / integration / sanity.js View on Github external
const jobOpenings = 'WE\'RE HIRING';
const joinSlug = 'join';
const joinURL = baseURL + '/join-us';
const workURL = baseURL + '/work';
const workItem = '.page-work .work-item';
const workReadmore = 'Read more';
const workSlug = 'work';
const sandboxURL = baseURL + '/sandbox';
const sandboxComponentList = 'body > ol';
const sandboxComponentName = 'blog';
const sandboxSlug = 'sandbox';
const badURL = baseURL + '/blog/press/asdf';
const page404 = '.page-404';

// helpers
wd.addPromiseChainMethod('openPageByMenuLink', (linkText) => {
  return browser
    .elementByCss(navigationToggle)
    .isDisplayed()
    .then((isDisplayed) => {
      if (isDisplayed) {
        console.log('We have a mobile menu so need to open it first...');
        return browser
          .elementByCss(navigationToggle)
          .click()
          .waitForElementByPartialLinkText(linkText.toUpperCase(), 5000)
          .click();
      } else {
        console.log('We are on desktop resolution now, no need to open mobile menu!');
        return browser
          .elementByPartialLinkText(linkText)
          .click();