How to use the chromedriver.version.match function in chromedriver

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 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)