Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/new headless mode in chrome #3581

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/transport/selenium-webdriver/options.js
Expand Up @@ -328,7 +328,7 @@ module.exports = class SeleniumCapabilities {

addHeadlessOption({options}) {
if (this.argv.headless && (options instanceof Capabilities) && (this.isChrome || options.headless)) {
this.isChrome ? options.addArguments('headless=chrome') : options.headless();
this.isChrome ? options.addArguments('headless=new') : options.headless();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the older versions of Chrome browser? Would --headless=new work with them as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to detect the version of the chrome browser before the driver creation. And people using older version of chrome will likely be using older version of nightwatch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should tag this as a breaking change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we can also detect the version of chromedriver, right? Since chromedriver version == chrome version.
(Of course, only if it is worth doing. But I guess we can also pass the --headless=chrome argument directly in desired capabilities and it will work for older chrome versions?)

}

return this;
Expand Down
2 changes: 1 addition & 1 deletion test/lib/command-mocks.js
Expand Up @@ -385,7 +385,7 @@ module.exports = {
url = '/wd/hub/session'
}) {
const browserName = 'chrome';
const headlessOpt = headless ? 'headless=chrome' : '';
const headlessOpt = headless ? 'headless=new' : '';
const options = {
['goog:chromeOptions']: {}
};
Expand Down
4 changes: 2 additions & 2 deletions test/src/core/testCreateSession.js
Expand Up @@ -198,7 +198,7 @@ describe('test Request With Credentials', function () {
sessionId: '1352110219202',
capabilities: {browserName: 'chrome', version: 'TEST', platform: 'TEST'}
});
assert.deepStrictEqual(sessionOptions.get('goog:chromeOptions'), {args: ['headless=chrome']});
assert.deepStrictEqual(sessionOptions.get('goog:chromeOptions'), {args: ['headless=new']});
});

it('Test create session with headless mode in Edge', async function () {
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('test Request With Credentials', function () {
assert.deepStrictEqual(sessionOptions.get('goog:chromeOptions'), {
args: [
'--no-sandbox',
'headless=chrome'
'headless=new'
]
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/src/index/transport/testChromeOptions.js
Expand Up @@ -108,7 +108,7 @@ describe('Test chrome options', function () {
const options = client.transport.createSessionOptions({headless: true});

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

it('devtools cli arg', function(){
Expand Down