ae-biu
Version:
Born For AE, Born To Do
39 lines (29 loc) • 1.68 kB
JavaScript
/**
* 将 Selenium 相关配置添加到 Nightwatch 配置中
* http://nightwatchjs.org/gettingstarted/#settings-file
*/
import path from 'path'
import phantomjs from 'phantomjs-prebuilt'
import merge from 'lodash/merge'
import { workDir, e2eFilePath } from '../utils/paths'
const driverPath = path.resolve(workDir, './node_modules/selenium-standalone/.selenium')
const defaultSettings = require(e2eFilePath('default-config.js'))
const seleniumConfig = require(e2eFilePath('selenium.config'))
export default function configure (customConfig) {
// 设置 Selenium 所在位置
defaultSettings.selenium.server_path = `${driverPath}/selenium-server/${seleniumConfig.version}-server.jar`
// 设置各 driver 所在位置
defaultSettings.selenium.cli_args['webdriver.gecko.driver'] =
`${driverPath}/geckodriver/${seleniumConfig.drivers.firefox.version}-${seleniumConfig.drivers.firefox.arch}-geckodriver`
defaultSettings.selenium.cli_args['webdriver.chrome.driver'] =
`${driverPath}/chromedriver/${seleniumConfig.drivers.chrome.version}-${seleniumConfig.drivers.chrome.arch}-chromedriver`
if (process.platform === 'win32') {
defaultSettings.selenium.cli_args['webdriver.ie.driver'] =
`${driverPath}/iedriver/${seleniumConfig.drivers.ie.version}-${seleniumConfig.drivers.ie.arch}-IEDriverServer.exe`
defaultSettings.selenium.cli_args['webdriver.edge.driver'] =
`${driverPath}/edgedriver/${seleniumConfig.drivers.edge.version}-MicrosoftEdgeDriver.exe`
}
// 设置 Phantom.JS.
defaultSettings.test_settings.default.desiredCapabilities['phantomjs.binary.path'] = phantomjs.path
return merge(defaultSettings, customConfig)
}