I want to have the latest browser engines without manually downloading them, thus I found webdriver manager. Though selenium documentation refers, regarding webdriver manager, that
// There is not a recommended driver manager for JavaScript at this time
I found though an NPM package named webdriver-manager
but they don't mention how to integrate it with nodeJs.
Right now, I am just running webdriver-manager update --out_dir ~/.local/bin/
to download the files into a directory included in PATH
, but I still have to rename the executable, because selenium-webdriver
does not detect them automatically.
I'm using the traditional code for headless browsers
const { Builder, By, until } = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
const firefox = require('selenium-webdriver/firefox')
//...
let driver
switch (browserForTest) { // browserForTest is fetched from argv
case 'firefox':
driver = await new Builder()
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().headless().windowSize(screen))
.build()
break
case 'chrome':
driver = await new Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().headless().windowSize(screen))
.build()
break
default:
throw Error('Wrong browser: ' + browserForTest)
}
Anyone has used webdriver-manager
with nodeJS? How do you integrate it?
How do you use selenium webdriver manager with node/javascript?