Skip to content

Commit

Permalink
Bump selenium-webdriver to 4.20.0 (#4206)
Browse files Browse the repository at this point in the history
Bump to selenium-webdriver 4.20.0
  • Loading branch information
garg3133 authored May 8, 2024
1 parent d0d3ccf commit cc8c830
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 35 deletions.
10 changes: 8 additions & 2 deletions lib/transport/selenium-webdriver/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,14 @@ module.exports = class SeleniumCapabilities {
}

addHeadlessOption({options}) {
if (this.argv.headless && (options instanceof Capabilities) && (this.isChrome || options.headless)) {
this.isChrome ? options.addArguments('headless=new') : options.headless();
if (this.argv.headless && (options instanceof Capabilities) && options.addArguments) {
// For other Chromium-based browsers, `options` wouldn't be an instance of Capabilities
// because it is never made so above (not officially supported by Selenium).
if (this.isChrome || this.isEdge) {
options.addArguments('headless=new');
} else if (this.isFirefox) {
options.addArguments('-headless');
}
}

return this;
Expand Down
44 changes: 20 additions & 24 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"open": "8.4.2",
"ora": "5.4.1",
"piscina": "^4.3.1",
"selenium-webdriver": "4.16.0",
"selenium-webdriver": "4.20.0",
"semver": "7.5.4",
"stacktrace-parser": "0.1.10",
"strip-ansi": "6.0.1",
Expand Down
6 changes: 3 additions & 3 deletions test/src/core/testCreateSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('test Request With Credentials', function () {
headless: true
}
});

assert.deepStrictEqual(session, {
sessionId: '1352110219202',
host: 'localhost',
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('test Request With Credentials', function () {
capabilities: {browserName: 'MicrosoftEdge', version: 'TEST', platform: 'TEST'}
});

assert.deepStrictEqual(sessionOptions.get('ms:edgeOptions'), {args: ['headless']});
assert.deepStrictEqual(sessionOptions.get('ms:edgeOptions'), {args: ['headless=new']});
});

it('Test create session with headless mode in Chrome with existing args', async function () {
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('test Request With Credentials', function () {
assert.deepStrictEqual(sessionOptions.get('ms:edgeOptions'), {
args: [
'--no-sandbox',
'headless'
'headless=new'
]
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/src/index/transport/testChromeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const Nightwatch = require('../../../lib/nightwatch.js');
const ChromeOptions = require('selenium-webdriver/chrome').Options;

describe('Test chrome options', function () {

it('Chrome option object with headless', function(){
const capabilities = new ChromeOptions();
capabilities.headless();
capabilities.addArguments('headless=new');

const client = Nightwatch.createClient({
capabilities
});
Expand Down
4 changes: 2 additions & 2 deletions test/src/index/transport/testEdgeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Test edge option', function(){

it('Edge option object with headless', function(){
const edgeoptions = new EdgeOptions();
edgeoptions.headless();
edgeoptions.addArguments('headless=new');

const client = Nightwatch.createClient({
capabilities: edgeoptions
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Test edge option', function(){
const options = client.transport.createSessionOptions({headless: true});

assert.strictEqual(options instanceof EdgeOptions, true);
assert.deepStrictEqual(options.options_.args, ['headless']);
assert.deepStrictEqual(options.options_.args, ['headless=new']);
});

it('window size option', function(){
Expand Down
3 changes: 2 additions & 1 deletion test/src/index/transport/testFirefoxOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ describe('Firefox driver options', function(){

it('Firefox option object with headless', function(){
const firefoxOptions = new FirefoxOptions();
firefoxOptions.headless();
firefoxOptions.addArguments('-headless');

const client = Nightwatch.createClient({
capabilities: firefoxOptions
});
Expand Down

0 comments on commit cc8c830

Please sign in to comment.