async setupDriverEnv()

in lib/driverProviders/local.ts [108:146]


  async setupDriverEnv(): Promise<any> {
    this.addDefaultBinaryLocs_();
    logger.info('Starting selenium standalone server...');

    let serverConf = this.config_.localSeleniumStandaloneOpts || {};

    // If args or port is not set use seleniumArgs and seleniumPort
    // for backward compatibility
    if (serverConf.args === undefined) {
      serverConf.args = this.config_.seleniumArgs || [];
    }
    if (serverConf.jvmArgs === undefined) {
      serverConf.jvmArgs = this.config_.jvmArgs || [];
    } else {
      if (!Array.isArray(serverConf.jvmArgs)) {
        throw new ConfigError(logger, 'jvmArgs should be an array.');
      }
    }
    if (serverConf.port === undefined) {
      serverConf.port = this.config_.seleniumPort;
    }

    // configure server
    if (this.config_.chromeDriver) {
      serverConf.jvmArgs.push('-Dwebdriver.chrome.driver=' + this.config_.chromeDriver);
    }
    if (this.config_.geckoDriver) {
      serverConf.jvmArgs.push('-Dwebdriver.gecko.driver=' + this.config_.geckoDriver);
    }

    this.server_ = new SeleniumServer(this.config_.seleniumServerJar, serverConf);

    // start local server, grab hosted address, and resolve promise
    const url = await this.server_.start(this.config_.seleniumServerStartTimeout);

    logger.info('Selenium standalone server started at ' + url);
    const address = await this.server_.address();
    this.config_.seleniumAddress = address;
  }