How to use the chimp.browser function in chimp

To help you get started, we’ve selected a few chimp 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 TheBrainFamily / chimpy / src / lib / chimp.js View on Github external
if (!this.options.domainOnly) {
    if (this.options.browser === 'phantomjs') {
      process.env['chimp.host'] = this.options.host = 'localhost';
      var phantom = new exports.Phantom(this.options);
      processes.push(phantom);
    }

    else if (userHasProvidedBrowser() && userHasNotProvidedSeleniumHost()) {
      process.env['chimp.host'] = this.options.host = 'localhost';
      var selenium = new exports.Selenium(this.options);
      processes.push(selenium);
    }

    else if (userHasNotProvidedSeleniumHost()) {
      // rewrite the browser to be chrome since "chromedriver" is not a valid browser
      process.env['chimp.browser'] = this.options.browser = 'chrome';
      process.env['chimp.host'] = this.options.host = 'localhost';
      var chromedriver = new exports.Chromedriver(this.options);
      processes.push(chromedriver);
    }
  }

  if (booleanHelper.isTruthy(this.options.mocha)) {
    var mocha = new exports.Mocha(this.options);
    processes.push(mocha);
  } else if (booleanHelper.isTruthy(this.options.jasmine)) {
    const jasmine = new exports.Jasmine(this.options);
    processes.push(jasmine);
  } else {
    if (booleanHelper.isTruthy(this.options.e2eSteps) || booleanHelper.isTruthy(this.options.domainSteps)) {
      // domain scenarios
      if (booleanHelper.isTruthy(this.options.domainSteps)) {
github TheBrainFamily / chimpy / dist / lib / cucumberjs / hooks.js View on Github external
this.registerHandler('AfterFeatures', function () {
    log.debug('[chimp][hooks] Starting AfterFeatures');

    if (process.env['chimp.browser'] !== 'phantomjs') {
      log.debug('[chimp][hooks] Ending browser session');

      global.wrapAsync(global.sessionManager.killCurrentSession, global.sessionManager)();
      log.debug('[chimp][hooks] Ended browser sessions');
    }

    log.debug('[chimp][hooks] Finished AfterFeatures');
  });
github TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
var initSingleBrowser = function (browser) {
      log.debug('[chimp][helper] init browser');
      log.debug('[chimp][helper] init browser callback');

      browser.screenshotsCount = 0;
      browser.addCommand('capture', function (name) {
        name = name.replace(/[ \\~#%&*{}/:<>?|"-]/g, '_');
        var location = (browser.screenshotsCount++) + '_' + name + '.png';
        fs.mkdirsSync(process.env['chimp.screenshotsPath']);
        var ssPath = path.join(process.env['chimp.screenshotsPath'], location);
        log.debug('[chimp][helper] saving screenshot to', ssPath);
        this.saveScreenshot(ssPath, false);
        log.debug('[chimp][helper] saved screenshot to', ssPath);
      });

      if (process.env['chimp.browser'] === 'phantomjs') {
        browser.setViewportSizeSync({
          width: process.env['chimp.phantom_w'] ? parseInt(process.env['chimp.phantom_w']):1280,
          height: process.env['chimp.phantom_h'] ? parseInt(process.env['chimp.phantom_h']):1024
        });
      }
    };
github TheBrainFamily / chimpy / dist / lib / chimp-helper.js View on Github external
var setupBrowser = function setupBrowser() {
      log.debug('[chimp][helper] getting browser');

      var webdriverioConfigOptions = JSON.parse(process.env['chimp.webdriverio']);
      var webdriverioOptions = (0, _deepExtend2.default)(webdriverioConfigOptions, {
        desiredCapabilities: {
          browserName: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.browser']),
          platform: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.platform']),
          name: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.name']),
          version: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.version']),
          deviceName: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.deviceName'])
        },
        user: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.user'] || process.env.SAUCE_USERNAME),
        key: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.key'] || process.env.SAUCE_ACCESS_KEY),
        host: (0, _environmentVariableParsers.parseNullableString)(process.env['chimp.host']),
        port: (0, _environmentVariableParsers.parseNullableInteger)(process.env['chimp.port']),
        logLevel: booleanHelper.isTruthy(process.env['chimp.debug']) ? 'verbose' : webdriverioConfigOptions.logLevel,
        sync: (0, _environmentVariableParsers.parseBoolean)(process.env['chimp.sync'])
      });

      global.sessionManager = new SessionFactory((0, _assign2.default)(_.pick(webdriverioOptions, 'host', 'port', 'user', 'key'), {
        browser: webdriverioOptions.desiredCapabilities.browserName,
        deviceName: webdriverioOptions.desiredCapabilities.deviceName
github TheBrainFamily / chimpy / src / lib / selenium.js View on Github external
if (self.options.seleniumDebug) {
        processHelper.logOutputs('selenium', self.child);
      }

      process.on('exit', function () {
        log.debug('[chimp][selenium] process exit event detected. Stopping process');
        self.stop(function () {
          log.debug('[chimp][selenium] process exit event stop complete');
        });
      });

      self.sessionManager = new SessionManager({
        host: process.env['chimp.host'],
        port: process.env['chimp.port'],
        browser: process.env['chimp.browser'],
        deviceName: process.env['chimp.deviceName']
      });

      callback(null);
    });
  });
github TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
var setupBrowser = function () {
      log.debug('[chimp][helper] getting browser');

      const webdriverioConfigOptions = JSON.parse(process.env['chimp.webdriverio']);
      const webdriverioOptions = merge(
        webdriverioConfigOptions,
        {
          desiredCapabilities: {
            browserName: parseNullableString(process.env['chimp.browser']),
            platform: parseNullableString(process.env['chimp.platform']),
            name: parseNullableString(process.env['chimp.name']),
            version: parseNullableString(process.env['chimp.browserVersion']),
            deviceName: parseNullableString(process.env['chimp.deviceName']),
          },
          user: parseNullableString(process.env['chimp.user'] || process.env.SAUCE_USERNAME),
          key: parseNullableString(process.env['chimp.key'] || process.env.SAUCE_ACCESS_KEY),
          host: parseNullableString(process.env['chimp.host']),
          port: parseNullableInteger(process.env['chimp.port']),
          logLevel: booleanHelper.isTruthy(process.env['chimp.debug']) ?
            'verbose' : webdriverioConfigOptions.logLevel,
          sync: parseBoolean(process.env['chimp.sync']),
        }
      );

      global.sessionManager = new SessionFactory(Object.assign(
github TheBrainFamily / chimpy / dist / lib / selenium.js View on Github external
if (self.options.seleniumDebug) {
        processHelper.logOutputs('selenium', self.child);
      }

      process.on('exit', function () {
        log.debug('[chimp][selenium] process exit event detected. Stopping process');
        self.stop(function () {
          log.debug('[chimp][selenium] process exit event stop complete');
        });
      });

      self.sessionManager = new SessionManager({
        host: process.env['chimp.host'],
        port: process.env['chimp.port'],
        browser: process.env['chimp.browser'],
        deviceName: process.env['chimp.deviceName']
      });

      callback(null);
    });
  });
github TheBrainFamily / chimpy / dist / lib / mocha / mocha-helper.js View on Github external
after(function () {
  if (process.env['chimp.browser'] !== 'phantomjs') {
    log.debug('[chimp][mocha-helper] Ending browser session');
    global.wrapAsync(global.sessionManager.killCurrentSession, global.sessionManager)();
    log.debug('[chimp][mocha-helper] Ended browser sessions');
  }
});
github TheBrainFamily / chimpy / src / lib / cucumberjs / hooks.js View on Github external
this.registerHandler('AfterFeatures', () => {
    log.debug('[chimp][hooks] Starting AfterFeatures');

    if (process.env['chimp.browser'] !== 'phantomjs') {
      log.debug('[chimp][hooks] Ending browser session');

      global.wrapAsync(global.sessionManager.killCurrentSession, global.sessionManager)();
      log.debug('[chimp][hooks] Ended browser sessions');
    }

    log.debug('[chimp][hooks] Finished AfterFeatures');
  });
github TheBrainFamily / chimpy / src / lib / mocha / mocha-helper.js View on Github external
after(function () {
  if (process.env['chimp.browser'] !== 'phantomjs') {
    log.debug('[chimp][mocha-helper] Ending browser session');
    global.wrapAsync(global.sessionManager.killCurrentSession, global.sessionManager)();
    log.debug('[chimp][mocha-helper] Ended browser sessions');
  }
});