How to use chromedriver - 10 common examples

To help you get started, we’ve selected a few chromedriver 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 zeit / next.js / test / jest-environment.js View on Github external
async teardown() {
    await super.teardown()
    if (this.server) this.server.close()
    if (browser) {
      // Close all remaining browser windows
      try {
        const windows = await browser.windowHandles()
        for (const window of windows) {
          if (!window) continue
          await browser.window(window)
          await browser.origClose()
          await browser.quit()
        }
      } catch (_) {}
    }
    chromedriver.stop()
  }
}
github B1naryStudio / CodeDoc / test / e2e.js View on Github external
import path from 'path';
import chromedriver from 'chromedriver';
import webdriver from 'selenium-webdriver';
import { expect } from 'chai';
import electronPath from 'electron-prebuilt';
import homeStyles from '../app/components/Home.module.css';
import counterStyles from '../app/components/Counter.module.css';

chromedriver.start(); // on port 9515
process.on('exit', chromedriver.stop);

const delay = time => new Promise(resolve => setTimeout(resolve, time));

describe('main window', function spec() {
  this.timeout(5000);

  before(async () => {
    await delay(1000); // wait chromedriver start time
    this.driver = new webdriver.Builder()
      .usingServer('http://localhost:9515')
      .withCapabilities({
        chromeOptions: {
          binary: electronPath,
          args: ['app=' + path.resolve()]
        }
github zeit / next.js / test / jest-environment.js View on Github external
async createBrowser() {
    // always create new browser session if not BrowserStack
    if (!browser) {
      if (!isBrowserStack) {
        driverPort = await getPort()
        chromedriver.start([`--port=${driverPort}`])

        // https://github.com/giggio/node-chromedriver/issues/117
        await waitPort({
          port: driverPort,
          timeout: 1000 * 60 * 2, // 2 Minutes
        })
      }

      browser = wd.promiseChainRemote(
        ...(isBrowserStack
          ? [
              'hub-cloud.browserstack.com', // seleniumHost
              80, // seleniumPort
              BROWSERSTACK_USERNAME,
              BROWSERSTACK_ACCESS_KEY,
            ]
github epicallan / tv-chicken / test / e2e.js View on Github external
import path from 'path';
import chromedriver from 'chromedriver';
import webdriver from 'selenium-webdriver';
import { expect } from 'chai';
import electronPath from 'electron-prebuilt';
import homeStyles from '../app/components/Home.module.css';
import counterStyles from '../app/components/Counter.module.css';

chromedriver.start(); // on port 9515
process.on('exit', chromedriver.stop);

const delay = time => new Promise(resolve => setTimeout(resolve, time));

describe.skip('main window', function spec() {
  this.timeout(5000);

  before(async () => {
    await delay(1000); // wait chromedriver start time
    this.driver = new webdriver.Builder()
      .usingServer('http://localhost:9515')
      .withCapabilities({
        chromeOptions: {
          binary: electronPath,
          args: ['app=' + path.resolve()]
        }
github freedomofpress / sunder / test / e2e.js View on Github external
import path from 'path';
import chromedriver from 'chromedriver';
import webdriver from 'selenium-webdriver';
import { expect } from 'chai';
import electronPath from 'electron-prebuilt';

chromedriver.start(); // on port 9515
process.on('exit', chromedriver.stop);

const delay = time => new Promise(resolve => setTimeout(resolve, time));

describe('main window', function spec() {
  this.timeout(5000);
  let shares; // Store the generated shares for recovery
  const quorum = 2;
  const numShares = 3;
  const secret = 'test secret';

  before(async () => {
    await delay(1000); // wait chromedriver start time
    this.driver = new webdriver.Builder()
      .usingServer('http://localhost:9515')
      .withCapabilities({
github experimentalDataAesthetics / play-splom / test / e2e.js View on Github external
import path from 'path';
import chromedriver from 'chromedriver';
import webdriver from 'selenium-webdriver';
import { expect } from 'chai';
import electronPath from 'electron-prebuilt';
import homeStyles from '../app/components/Home.css';
import counterStyles from '../app/components/Counter.css';

chromedriver.start(); // on port 9515
process.on('exit', chromedriver.stop);

const delay = time => new Promise(resolve => setTimeout(resolve, time));

describe('main window', function spec() {
  this.timeout(5000);

  before(async () => {
    await delay(1000); // wait chromedriver start time
    this.driver = new webdriver.Builder()
      .usingServer('http://localhost:9515')
      .withCapabilities({
        chromeOptions: {
          binary: electronPath,
          args: [`app=${path.resolve()}`]
        }
github vuejs / vue-cli / packages / @vue / cli-plugin-e2e-nightwatch / index.js View on Github external
}, (args, rawArgs) => {
    if (args.env && args.env.includes('firefox')) {
      try {
        require('geckodriver')
      } catch (e) {
        error(`To run e2e tests in Firefox, you need to install ${chalk.yellow.bold('geckodriver')} first.`)
        process.exit(1)
      }
    }
    if (installedBrowsers.chrome) {
      const userVersion = installedBrowsers.chrome
      const driverVersion = require('chromedriver').version

      const userMajor = userVersion.match(/^(\d+)\./)[1]
      const driverMajor = driverVersion.match(/^(\d+)\./)[1]

      if (userMajor !== driverMajor) {
        warn(`Local ${chalk.cyan.bold('Chrome')} version is ${chalk.cyan.bold(userMajor)}, but the installed ${chalk.cyan.bold('chromedriver')} is for version ${chalk.cyan.bold(driverMajor)}.`)
        warn(`There may be incompatibilities between them.`)
        warn(`Please update your ${chalk.cyan.bold('chromedriver')} dependency to match the ${chalk.cyan.bold('Chrome')} version.`)
      }
    }

    // remove args
    ;['url', 'mode'].forEach(toRemove => removeArg(rawArgs, toRemove))
    // remove flags
    ;['headless', 'use-selenium', 'parallel'].forEach(toRemove => removeArg(rawArgs, toRemove, 0))
github vuejs / vue-cli / packages / @vue / cli-plugin-e2e-nightwatch / index.js View on Github external
}, (args, rawArgs) => {
    if (args.env && args.env.includes('firefox')) {
      try {
        require('geckodriver')
      } catch (e) {
        error(`To run e2e tests in Firefox, you need to install ${chalk.yellow.bold('geckodriver')} first.`)
        process.exit(1)
      }
    }
    if (installedBrowsers.chrome) {
      const userVersion = installedBrowsers.chrome
      const driverVersion = require('chromedriver').version

      const userMajor = userVersion.match(/^(\d+)\./)[1]
      const driverMajor = driverVersion.match(/^(\d+)\./)[1]

      if (userMajor !== driverMajor) {
        warn(`Local ${chalk.cyan.bold('Chrome')} version is ${chalk.cyan.bold(userMajor)}, but the installed ${chalk.cyan.bold('chromedriver')} is for version ${chalk.cyan.bold(driverMajor)}.`)
        warn(`There may be incompatibilities between them.`)
        warn(`Please update your ${chalk.cyan.bold('chromedriver')} dependency to match the ${chalk.cyan.bold('Chrome')} version.`)
      }
    }

    // remove args
    ;['url', 'mode'].forEach(toRemove => removeArg(rawArgs, toRemove))
    // remove flags
    ;['headless', 'use-selenium', 'parallel'].forEach(toRemove => removeArg(rawArgs, toRemove, 0))

    return Promise.all([
      startDevServer(args, api),
      loadNightwatchConfig(rawArgs, api)
github kazupon / vue-plugin-boilerplate / template / config / nightwatch.conf.js View on Github external
// http://nightwatchjs.org/guide#settings-file
module.exports = {
  src_folders: ['test/e2e/test'],
  output_folder: 'test/e2e/report',
  custom_commands_path: ['node_modules/nightwatch-helpers/commands'],
  custom_assertions_path: ['node_modules/nightwatch-helpers/assertions'],

  selenium: {
    start_process: true,
    server_path: 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar',
    host: '127.0.0.1',
    port: 4444,
    cli_args: {
      'webdriver.chrome.driver': require('chromedriver').path
    }
  },

  test_settings: {
    default: {
      selenium_port: 4444,
      selenium_host: 'localhost',
      silent: true,
      screenshots: {
        enabled: true,
        on_failure: true,
        on_error: false,
        path: 'test/e2e/screenshots'
      }
    },
github jan-molak / serenity-js / examples / protractor-cucumber / protractor.conf.js View on Github external
const
    { ConsoleReporter } = require('@serenity-js/console-reporter'),
    { ArtifactArchiver, StreamReporter } = require('@serenity-js/core'),
    { SerenityBDDReporter } = require('@serenity-js/serenity-bdd');

exports.config = {
    chromeDriver: require('chromedriver/lib/chromedriver').path,
    SELENIUM_PROMISE_MANAGER: false,

    directConnect: true,

    allScriptsTimeout: 11000,

    specs: [ 'features/*.feature', ],

    framework:      'custom',
    frameworkPath:  require.resolve('@serenity-js/protractor/adapter'),

    serenity: {
        crew: [
            ArtifactArchiver.storingArtifactsAt('./target/site/serenity'),
            new SerenityBDDReporter(),
            // ConsoleReporter.forDarkTerminals(),