Skip to content

Commit

Permalink
fix(webdriverjs): use new headless argument to fix selenium-webdriver…
Browse files Browse the repository at this point in the history
…@4.17.0 breaking release (#992)

* fix(webdriverjs): use new headless argument to fix selenium-webdriver@4.17.0 breaking release

* fix webdriverjs tests to use addArguments too

* fix cli test

* use --headless instead of --headless=new

* use headless to reduce change diff
  • Loading branch information
straker committed Jan 23, 2024
1 parent 2220400 commit 0daba98
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"chromedriver": "latest",
"colors": "^1.4.0",
"commander": "^9.4.1",
"selenium-webdriver": "^4.8.1"
"selenium-webdriver": "~4.17.0"
},
"devDependencies": {
"@types/chai": "^4.3.3",
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/lib/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ const startDriver = async (
config.chromedriverPath || chromedriver.path
);

let options = new chrome.Options().headless();
let options = new chrome.Options();
// selenium-webdriver < 4.17.0
if (typeof options.headless === 'function') {
options.headless();
}
// selenium-webdriver >= 4.17.0
else {
options.addArguments('headless');
}

if (config.chromeOptions?.length) {
options = config.chromeOptions.reduce(function (options, arg) {
return options.addArguments(arg);
Expand Down
2 changes: 1 addition & 1 deletion packages/webdriverjs/test/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chrome from 'selenium-webdriver/chrome';
export const Webdriver = (): WebDriver => {
const builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().headless())
.setChromeOptions(new chrome.Options().addArguments('headless'))
.setChromeService(
new chrome.ServiceBuilder(
process.env.CHROMEDRIVER_PATH || chromedriver.path
Expand Down

0 comments on commit 0daba98

Please sign in to comment.