本文整理汇总了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;未经允许,请勿转载。 |
请发表评论