How to use the selenium-webdriver/chrome.ServiceBuilder function in selenium-webdriver

To help you get started, we’ve selected a few selenium-webdriver 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 Harkishen-Singh / Jarvis-personal-assistant / tests / subs.js View on Github external
process.argv.forEach((val, index, array) => {
    var path = require('chromedriver').path;

    var service = new chrome.ServiceBuilder(path).build();
    chrome.setDefaultService(service);
    if (index === 2) { // corresponds to the emailID heroku
        email = val;
    } else if (index == 3) { // corresponds to password heroku
        password = val;
    } else if(index == 3) { // corresponds to search url
        url = val;

        // keep the below block of code in the last part the else if block

        var options = new chrome.Options();
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--disable-gpu");
        // options.addArguments("--headless");
        var arrAnswer = [];
github dequelabs / axe-cli / lib / webdriver.js View on Github external
function startDriver(config) {
	let builder;
	const scriptTimeout = (config.timeout || 20) * 1000.0;

	if (config.browser === 'chrome-headless') {
		// Tell selenium use the driver in node_modules
		const service = new chrome.ServiceBuilder(
			config.chromedriverPath || chromedriver.path
		).build();
		chrome.setDefaultService(service);

		const args = ['--headless'];
		if (config.chromeOptions) {
			args.push(...config.chromeOptions);
		}

		const chromeCapabilities = Capabilities.chrome();
		chromeCapabilities.set('chromeOptions', { args });

		builder = new Builder()
			.forBrowser('chrome')
			.withCapabilities(chromeCapabilities);
	} else {
github angular / protractor / lib / driverProviders / direct.ts View on Github external
} catch (e) {
            throw new BrowserError(
                logger,
                'Could not find update-config.json. ' +
                    'Run \'webdriver-manager update\' to download binaries.');
          }
        }

        if (!fs.existsSync(chromeDriverFile)) {
          throw new BrowserError(
              logger,
              'Could not find chromedriver at ' + chromeDriverFile +
                  '. Run \'webdriver-manager update\' to download binaries.');
        }

        let chromeService = new ChromeServiceBuilder(chromeDriverFile).build();
        // driver = ChromeDriver.createSession(new Capabilities(this.config_.capabilities),
        // chromeService);
        // TODO(ralphj): fix typings
        driver =
            require('selenium-webdriver/chrome')
                .Driver.createSession(new Capabilities(this.config_.capabilities), chromeService);
        break;
      case 'firefox':
        let geckoDriverFile: string;
        try {
          let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
          let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
          geckoDriverFile = updateConfig.gecko.last;
        } catch (e) {
          throw new BrowserError(
              logger,
github Harkishen-Singh / Jarvis-personal-assistant / service / subprocesses / fetchdata_query.js View on Github external
process.argv.forEach((val, index, array) => {
    var path = require('chromedriver').path;

    var service = new chrome.ServiceBuilder(path).build();
    chrome.setDefaultService(service);
    if (index === 2) { // corresponds to the search method
        method = val;
    } else if(index == 3) { // corresponds to search url
        url = val;

        // keep the below block of code in the last part the else if block

        var options = new chrome.Options();
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--disable-gpu");
        options.addArguments("--headless");

        var driver = new webdriver.Builder()
                            .setChromeOptions(options)
github multiparty / web-mpc / test / selenium / mocha_tests.js View on Github external
function createDriver() {
  var service = new chrome.ServiceBuilder(path).build();
    chrome.setDefaultService(service);
  var driver = new webdriver.Builder()
    .forBrowser('chrome')
    .withCapabilities(webdriver.Capabilities.chrome())
    .build();

  return driver;
}
github square / field-kit / test / selenium / index.js View on Github external
test.before(function() {
    var webdriver = require('selenium-webdriver');
    var builder = new webdriver.Builder();

    if (process.env.CONTINUOUS_INTEGRATION) {
      builder.forBrowser('firefox');
    } else {
      var chrome = require('selenium-webdriver/chrome');
      var path = require('chromedriver').path;

      var service = new chrome.ServiceBuilder(path).build();
      chrome.setDefaultService(service);

      builder.withCapabilities(webdriver.Capabilities.chrome())
    }

    driver = builder.build();

    server.start();
  });
github marmelab / selenium-smart-wait / e2e / chromeWebDriver.js View on Github external
import webdriver from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome';
import logging from 'selenium-webdriver/lib/logging';
import path from 'path';

const chromePath = path.join(__dirname, '/../', process.env.SELENIUM_BROWSER_BINARY_PATH);
const service = new chrome.ServiceBuilder(chromePath).build();
const DEFAULT_WAIT_TIMEOUT = 1000;

chrome.setDefaultService(service);

const chromeCapabilities = webdriver.Capabilities.chrome();
if (process.env.DEBUG) {
    const prefs = new logging.Preferences();
    prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
    chromeCapabilities.setLoggingPrefs(prefs);
}

const chromeOptions = {
    args: ['--test-type', '--start-maximized', '--incognito'],
};

chromeCapabilities.set('chromeOptions', chromeOptions);
github smithclay / lambdium / src / lib / chromium.js View on Github external
exports.createSession = function() {
  var service;
  if (process.env.LOG_DEBUG || process.env.SAM_LOCAL) {
    service = new chrome.ServiceBuilder(CHROMEDRIVER_PATH)
      .loggingTo('/tmp/chromedriver.log')
      .build();
  } else {
    service = new chrome.ServiceBuilder(CHROMEDRIVER_PATH)
      .build();
  }

  const options = new chrome.Options();

  const logPrefs = new webdriver.logging.Preferences();
  logPrefs.setLevel(webdriver.logging.Type.PERFORMANCE, webdriver.logging.Level.ALL);
  options.setLoggingPrefs(logPrefs);

  options.setPerfLoggingPrefs({ enableNetwork: true, enablePage: true });
  options.setChromeBinaryPath(HEADLESS_CHROME_PATH);
  options.addArguments(defaultChromeFlags);
  return chrome.Driver.createSession(options, service);
}
github wazuh / wazuh-kibana-app / server / reporting / auto-report.ts View on Github external
async createDriver() {
    Chrome.setDefaultService(new Chrome.ServiceBuilder(Chromedriver.path).build());
    return await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(new Chrome.Options().headless().windowSize(this.screen))
    .build();
  }
github smithclay / lambdium / src / lib / chromium.js View on Github external
exports.createSession = function() {
  var service;
  if (process.env.LOG_DEBUG || process.env.SAM_LOCAL) {
    service = new chrome.ServiceBuilder(CHROMEDRIVER_PATH)
      .loggingTo('/tmp/chromedriver.log')
      .build();
  } else {
    service = new chrome.ServiceBuilder(CHROMEDRIVER_PATH)
      .build();
  }

  const options = new chrome.Options();

  const logPrefs = new webdriver.logging.Preferences();
  logPrefs.setLevel(webdriver.logging.Type.PERFORMANCE, webdriver.logging.Level.ALL);
  options.setLoggingPrefs(logPrefs);

  options.setPerfLoggingPrefs({ enableNetwork: true, enablePage: true });
  options.setChromeBinaryPath(HEADLESS_CHROME_PATH);
  options.addArguments(defaultChromeFlags);