當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript config.Config類代碼示例

本文整理匯總了TypeScript中webdriver-manager/built/lib/config.Config的典型用法代碼示例。如果您正苦於以下問題:TypeScript Config類的具體用法?TypeScript Config怎麽用?TypeScript Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: addDefaultBinaryLocs_

  /**
   * Helper to locate the default jar path if none is provided by the user.
   * @private
   */
  addDefaultBinaryLocs_(): void {
    if (!this.config_.seleniumServerJar) {
      logger.debug(
          'Attempting to find the SeleniumServerJar in the default ' +
          'location used by webdriver-manager');
      this.config_.seleniumServerJar = path.resolve(
          SeleniumConfig.getSeleniumDir(), new SeleniumStandAlone().executableFilename());
    }
    if (!fs.existsSync(this.config_.seleniumServerJar)) {
      throw new BrowserError(
          logger,
          'No selenium server jar found at the specified ' +
              'location (' + this.config_.seleniumServerJar +
              '). Check that the version number is up to date.');
    }
    if (this.config_.capabilities.browserName === 'chrome') {
      if (!this.config_.chromeDriver) {
        logger.debug(
            'Attempting to find the chromedriver binary in the default ' +
            'location used by webdriver-manager');
        this.config_.chromeDriver = path.resolve(
            SeleniumConfig.getSeleniumDir(), new SeleniumChrome().executableFilename());
      }

      // Check if file exists, if not try .exe or fail accordingly
      if (!fs.existsSync(this.config_.chromeDriver)) {
        if (fs.existsSync(this.config_.chromeDriver + '.exe')) {
          this.config_.chromeDriver += '.exe';
        } else {
          throw new BrowserError(
              logger, 'Could not find chromedriver at ' + this.config_.chromeDriver);
        }
      }
    }
  }
開發者ID:sohelsaiyed,項目名稱:protractor,代碼行數:39,代碼來源:local.ts

示例2: addDefaultBinaryLocs_

  /**
   * Helper to locate the default jar path if none is provided by the user.
   * @private
   */
  addDefaultBinaryLocs_(): void {
    if (!this.config_.seleniumServerJar) {
      logger.debug(
          'Attempting to find the SeleniumServerJar in the default ' +
          'location used by webdriver-manager');
      try {
        let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
        let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
        this.config_.seleniumServerJar = updateConfig.standalone.last;
      } catch (err) {
        throw new BrowserError(
            logger,
            'No update-config.json found.' +
                ' Run \'webdriver-manager update\' to download binaries.');
      }
    }
    if (!fs.existsSync(this.config_.seleniumServerJar)) {
      throw new BrowserError(
          logger,
          'No selenium server jar found at ' + this.config_.seleniumServerJar +
              '. Run \'webdriver-manager update\' to download binaries.');
    }
    if (this.config_.capabilities.browserName === 'chrome') {
      if (!this.config_.chromeDriver) {
        logger.debug(
            'Attempting to find the chromedriver binary in the default ' +
            'location used by webdriver-manager');

        try {
          let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
          let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
          this.config_.chromeDriver = updateConfig.chrome.last;
        } catch (err) {
          throw new BrowserError(
              logger,
              'No update-config.json found. ' +
                  'Run \'webdriver-manager update\' to download binaries.');
        }
      }

      // Check if file exists, if not try .exe or fail accordingly
      if (!fs.existsSync(this.config_.chromeDriver)) {
        if (fs.existsSync(this.config_.chromeDriver + '.exe')) {
          this.config_.chromeDriver += '.exe';
        } else {
          throw new BrowserError(
              logger,
              'Could not find chromedriver at ' + this.config_.chromeDriver +
                  '. Run \'webdriver-manager update\' to download binaries.');
        }
      }
    }
  }
開發者ID:igniteram,項目名稱:protractor,代碼行數:57,代碼來源:local.ts

示例3: getNewDriver

  /**
   * Create a new driver.
   *
   * @public
   * @override
   * @return webdriver instance
   */
  getNewDriver(): webdriver.WebDriver {
    let driver: webdriver.WebDriver;
    switch (this.config_.capabilities.browserName) {
      case 'chrome':
        let defaultChromeDriverPath = path.resolve(
            SeleniumConfig.getSeleniumDir(), new SeleniumChrome().executableFilename());

        if (process.platform.indexOf('win') === 0) {
          defaultChromeDriverPath += '.exe';
        }

        let chromeDriverFile = this.config_.chromeDriver || defaultChromeDriverPath;

        if (!fs.existsSync(chromeDriverFile)) {
          throw new BrowserError(logger, 'Could not find chromedriver at ' + chromeDriverFile);
        }

        let service = new chrome.ServiceBuilder(chromeDriverFile).build();
        driver = new chrome.Driver(new webdriver.Capabilities(this.config_.capabilities), service);
        break;
      case 'firefox':
        if (this.config_.firefoxPath) {
          this.config_.capabilities['firefox_binary'] = this.config_.firefoxPath;
        }
        driver = new firefox.Driver(this.config_.capabilities);
        break;
      default:
        throw new BrowserError(
            logger,
            'browserName ' + this.config_.capabilities.browserName +
                ' is not supported with directConnect.');
    }
    this.drivers_.push(driver);
    return driver;
  }
開發者ID:sohelsaiyed,項目名稱:protractor,代碼行數:42,代碼來源:direct.ts

示例4: getNewDriver

  /**
   * Create a new driver.
   *
   * @public
   * @override
   * @return webdriver instance
   */
  getNewDriver(): WebDriver {
    let driver: WebDriver;

    switch (this.config_.capabilities.browserName) {
      case 'chrome':
        let chromeDriverFile: string;
        if (this.config_.chromeDriver) {
          chromeDriverFile = this.config_.chromeDriver;
        } else {
          try {
            let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
            let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
            chromeDriverFile = updateConfig.chrome.last;
          } 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':
        if (this.config_.firefoxPath) {
          this.config_.capabilities['firefox_binary'] = this.config_.firefoxPath;
        }

        // TODO(cnishina): Add in a service builder with marionette. Direct connect
        // currently supports FF legacy version 47.
        driver = require('selenium-webdriver/firefox')
                     .Driver.createSession(new Capabilities(this.config_.capabilities));
        break;
      default:
        throw new BrowserError(
            logger,
            'browserName ' + this.config_.capabilities.browserName +
                ' is not supported with directConnect.');
    }
    this.drivers_.push(driver);
    return driver;
  }
開發者ID:JesseChezenko-AI,項目名稱:protractor,代碼行數:62,代碼來源:direct.ts

示例5: getNewDriver

  /**
   * Create a new driver.
   *
   * @public
   * @override
   * @return webdriver instance
   */
  getNewDriver(): WebDriver {
    let driver: WebDriver;

    switch (this.config_.capabilities.browserName) {
      case 'chrome':
        let chromeDriverFile: string;
        if (this.config_.chromeDriver) {
          chromeDriverFile = this.config_.chromeDriver;
        } else {
          try {
            let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
            let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
            chromeDriverFile = updateConfig.chrome.last;
          } 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;
        if (this.config_.geckoDriver) {
          geckoDriverFile = this.config_.geckoDriver;
        } else {
          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,
                'Could not find update-config.json. ' +
                    'Run \'webdriver-manager update\' to download binaries.');
          }
        }

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

        // TODO (mgiambalvo): Turn this into an import when the selenium typings are updated.
        const FirefoxServiceBuilder = require('selenium-webdriver/firefox').ServiceBuilder;

        let firefoxService = new FirefoxServiceBuilder(geckoDriverFile).build();
        // TODO(mgiambalvo): Fix typings.
        driver =
            require('selenium-webdriver/firefox')
                .Driver.createSession(new Capabilities(this.config_.capabilities), firefoxService);
        break;
      default:
        throw new BrowserError(
            logger,
            'browserName ' + this.config_.capabilities.browserName +
                ' is not supported with directConnect.');
    }
    this.drivers_.push(driver);
    return driver;
  }
開發者ID:DylanLacey,項目名稱:protractor,代碼行數:85,代碼來源:direct.ts


注:本文中的webdriver-manager/built/lib/config.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。