Created
March 2, 2017 08:39
-
-
Save giltayar/c6aa5417aac38080a0b4ad3cb804947b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webdriver = require('selenium-webdriver') | |
const chromeDriver = require('chromedriver') | |
const path = require('path') | |
const chromeDriverPathAddition = `:${path.dirname(chromeDriver.path)}` | |
exports.prepareDriver = async () => { | |
process.on('beforeExit', () => this.browser && this.browser.quit()) | |
process.env.PATH += chromeDriverPathAddition | |
return await new webdriver.Builder() | |
.disableEnvironmentOverrides() | |
.forBrowser('chrome') | |
.setLoggingPrefs({browser: 'ALL', driver: 'ALL'}) | |
.build() | |
} | |
exports.cleanupDriver = async (driver) => { | |
if (driver) { | |
driver.quit() | |
} | |
process.env.PATH = process.env.PATH.replace(chromeDriverPathAddition, '') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment