ui5-test-runner
Version:
Standalone test runner for UI5
40 lines (34 loc) • 1.05 kB
JavaScript
const { join } = require('path')
module.exports = async ({
seleniumWebdriver,
settings,
options,
loggingPreferences
}) => {
const { Browser, Builder } = seleniumWebdriver
const chrome = require(join(settings.modules['selenium-webdriver'], 'chrome'))
const chromeOptions = new chrome.Options()
const chromeArgs = options.chromeArgs()
for (const arg of chromeArgs) {
if (arg !== 'true') {
chromeOptions.addArguments(arg)
}
}
chromeOptions.setLoggingPrefs(loggingPreferences)
if (options.binary) {
chromeOptions.setChromeBinaryPath(options.binary)
}
chromeOptions.excludeSwitches('--enable-logging')
const builder = new Builder()
.forBrowser(Browser.CHROME)
.setChromeOptions(chromeOptions)
if (options.server) {
builder.usingServer(options.server)
}
const driver = await builder.build()
driver.__console__ = true
driver.__addScript__ = async function (source) {
return await driver.sendDevToolsCommand('Page.addScriptToEvaluateOnNewDocument', { source })
}
return driver
}