Hello!
chromeOptions "start-maximized" or "start-fullscreen" doesn't work with "--headless" arg, but works fine without "--headless" arg.
This is part of nightwatch.conf.js, with which problem is reproduced:
desiredCapabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"start-maximized",
"--headless"
]
}
}
This is simple test for checking window size:
test (browser) {
browser.windowSize("current", function(result) {
console.log(result.value);
});
}
In this case in console:
{ height: 600, width: 800 }
Buf after removing "--headless" from args of chromeOptions I see such (right) output in console:
{ height: 1026, width: 1696 }
And additionally I've saved screenshots in two scenarios. And here also the same result.
nightwatch v1.3.5
chromedriver v81.0.0
node.js v12.16.2
npm v6.14.4
windows 10
Click to hide(show)!
Starting ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1590053762.235][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] COMMAND InitSession {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [ "--headless", "start-maximized" ]
},
"name": "Src\\test",
"platform": "ANY"
}
}
[1590053762.237][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_setting_values": {
"geolocation": 1
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[1590053762.241][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[1590053762.248][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --load-extension="C:\Users\HTPC\AppData\Local\Temp\scoped_dir11384_934527131\internal" --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --start-maximized --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\HTPC\AppData\Local\Temp\scoped_dir11384_4565296" data:,
[1590053762.416][DEBUG]: DevTools HTTP Request: http://localhost:56987/json/version
[1590053762.730][DEBUG]: DevTools HTTP Response: {
"Browser": "HeadlessChrome/81.0.4044.138",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/81.0.4044.138 Safari/537.36",
"V8-Version": "8.1.307.32",
"WebKit-Version": "537.36 (@8c6c7ba89cc9453625af54f11fd83179e23450fa)",
"webSocketDebuggerUrl": "ws://localhost:56987/devtools/browser/b22e9301-3a5c-4a92-858f-286471ef4406"
}
[1590053762.732][DEBUG]: DevTools HTTP Request: http://localhost:56987/json/list
[1590053762.734][DEBUG]: DevTools HTTP Response: [ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:56987/devtools/page/9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"id": "9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"title": "data:,",
"type": "page",
"url": "data:,",
"webSocketDebuggerUrl": "ws://localhost:56987/devtools/page/9D70B2CD6F181A8070BFBC2F6D9CDC8C"
} ]
[1590053762.737][DEBUG]: DevTools HTTP Request: http://localhost:56987/json/list
[1590053762.740][DEBUG]: DevTools HTTP Response: [ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:56987/devtools/page/9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"id": "9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"title": "data:,",
"type": "page",
"url": "data:,",
"webSocketDebuggerUrl": "ws://localhost:56987/devtools/page/9D70B2CD6F181A8070BFBC2F6D9CDC8C"
} ]
[1590053762.748][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1590053764.753][DEBUG]: DevTools WebSocket Command: Page.addScriptToEvaluateOnNewDocument (id=1) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"source": "(function () {window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;}) ();"
}
[1590053764.755][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=2) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"expression": "(function () {window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;}) ();"
}
[1590053764.756][DEBUG]: DevTools WebSocket Command: Log.enable (id=3) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.757][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=4) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.757][DEBUG]: DevTools WebSocket Command: Target.setAutoAttach (id=5) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"autoAttach": true,
"flatten": true,
"waitForDebuggerOnStart": false
}
[1590053764.758][DEBUG]: DevTools WebSocket Command: Page.enable (id=6) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.759][DEBUG]: DevTools WebSocket Command: Page.setDownloadBehavior (id=7) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"behavior": "allow",
"downloadPath": "."
}
[1590053764.760][DEBUG]: DevTools WebSocket Command: Page.enable (id=8) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.760][DEBUG]: DevTools WebSocket Response: Page.addScriptToEvaluateOnNewDocument (id=1) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"identifier": "1"
}
[1590053764.761][DEBUG]: DevTools WebSocket Response: Page.setDownloadBehavior (id=7) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.762][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=2) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"result": {
"type": "undefined"
}
}
[1590053764.762][DEBUG]: DevTools WebSocket Response: Log.enable (id=3) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.763][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=4) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"root": {
"backendNodeId": 2,
"baseURL": "data:,",
"childNodeCount": 1,
"children": [ {
"attributes": [ ],
"backendNodeId": 3,
"childNodeCount": 2,
"children": [ {
"attributes": [ ],
"backendNodeId": 4,
"childNodeCount": 0,
"localName": "head",
"nodeId": 3,
"nodeName": "HEAD",
"nodeType": 1,
"nodeValue": "",
"parentId": 2
}, {
"attributes": [ ],
"backendNodeId": 5,
"childNodeCount": 0,
"localName": "body",
"nodeId": 4,
"nodeName": "BODY",
"nodeType": 1,
"nodeValue": "",
"parentId": 2
} ],
"frameId": "9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"localName": "html",
"nodeId": 2,
"nodeName": "HTML",
"nodeType": 1,
"nodeValue": "",
"parentId": 1
} ],
"documentURL": "data:,",
"localName": "",
"nodeId": 1,
"nodeName": "#document",
"nodeType": 9,
"nodeValue": "",
"xmlVersion": ""
}
}
[1590053764.768][DEBUG]: DevTools WebSocket Response: Target.setAutoAttach (id=5) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.768][DEBUG]: DevTools WebSocket Response: Page.enable (id=6) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.769][DEBUG]: DevTools WebSocket Response: Page.enable (id=8) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.769][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=9) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.771][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"context": {
"auxData": {
"frameId": "9D70B2CD6F181A8070BFBC2F6D9CDC8C",
"isDefault": true,
"type": "default"
},
"id": 1,
"name": "",
"origin": "://"
}
}
[1590053764.771][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=9) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.772][DEBUG]: DevTools WebSocket Command: Page.enable (id=10) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.772][DEBUG]: DevTools WebSocket Response: Page.enable (id=10) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.773][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=11) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.774][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=11) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
}
[1590053764.774][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=12) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"awaitPromise": true,
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[1590053764.777][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=12) 9D70B2CD6F181A8070BFBC2F6D9CDC8C {
"result": {
"type": "object",
"value": {
"status": 0,
"value": 1
}
}
}
[1590053764.778][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] RESPONSE InitSession {
"acceptInsecureCerts": false,
"acceptSslCerts": false,
"applicationCacheEnabled": false,
"browserConnectionEnabled": false,
"browserName": "chrome",
"chrome": {
"chromedriverVersion": "81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776})",
"userDataDir": "C:\\Users\\HTPC\\AppData\\Local\\Temp\\scoped_dir11384_4565296"
},
"cssSelectorsEnabled": true,
"databaseEnabled": false,
"goog:chromeOptions": {
"debuggerAddress": "localhost:56987"
},
"handlesAlerts": true,
"hasTouchScreen": false,
"javascriptEnabled": true,
"locationContextEnabled": true,
"mobileEmulationEnabled": false,
"nativeEvents": true,
"networkConnectionEnabled": false,
"pageLoadStrategy": "normal",
"platform": "Windows",
"proxy": {
},
"~~~": "..."
}
[1590053764.812][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] COMMAND GetWindowSize {
"windowHandle": "current"
}
[1590053764.812][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1590053766.815][DEBUG]: DevTools WebSocket Command: Browser.getWindowForTarget (id=1) browser {
"targetId": "9D70B2CD6F181A8070BFBC2F6D9CDC8C"
}
[1590053766.817][DEBUG]: DevTools WebSocket Response: Browser.getWindowForTarget (id=1) browser {
"bounds": {
"height": 600,
"left": 0,
"top": 0,
"width": 800,
"windowState": "normal"
},
"windowId": 1
}
[1590053766.818][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] RESPONSE GetWindowSize {
"height": 600,
"width": 800
}
[1590053766.848][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] COMMAND Quit {
}
[1590053766.865][INFO]: [6e3cf3d0e7109d6e37dbf2a80f2df3d7] RESPONSE Quit
[1590053766.866][DEBUG]: Log type 'driver' lost 0 entries on destruction
[1590053766.866][DEBUG]: Log type 'browser' lost 0 entries on destruction
Click to hide(show)!
> nightwatch --verbose
Starting ChromeDriver on port 9515...
ChromeDriver up and running on port 9515 with pid: 11384 (156ms).
[Src\test] Test Suite
=====================
- Connecting to localhost on port 9515...
Request POST /session
{
desiredCapabilities: {
browserName: 'chrome',
platform: 'ANY',
chromeOptions: { args: [ '--headless', 'start-maximized' ] },
name: 'Src\\test'
}
\ Connecting to localhost on port 9515...
/ Connecting to localhost on port 9515...
Response 200 POST /session (2556ms)
{
sessionId: '6e3cf3d0e7109d6e37dbf2a80f2df3d7',
status: 0,
value: {
acceptInsecureCerts: false,
acceptSslCerts: false,
applicationCacheEnabled: false,
browserConnectionEnabled: false,
browserName: 'chrome',
chrome: {
chromedriverVersion: '81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776})',
userDataDir: 'C:\\Users\\HTPC\\AppData\\Local\\Temp\\scoped_dir11384_4565296'
},
cssSelectorsEnabled: true,
databaseEnabled: false,
'goog:chromeOptions': { debuggerAddress: 'localhost:56987' },
handlesAlerts: true,
hasTouchScreen: false,
javascriptEnabled: true,
locationContextEnabled: true,
mobileEmulationEnabled: false,
nativeEvents: true,
networkConnectionEnabled: false,
pageLoadStrategy: 'normal',
platform: 'Windows',
proxy: {},
rotatable: false,
setWindowRect: true,
strictFileInteractability: false,
takesHeapSnapshot: true,
takesScreenshot: true,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
unexpectedAlertBehaviour: 'ignore',
version: '81.0.4044.138',
webStorageEnabled: true,
'webauthn:virtualAuthenticators': true
}
i Connected to localhost on port 9515 (2635ms).
Using: chrome (81.0.4044.138) on Windows platform.
Received session with ID: 6e3cf3d0e7109d6e37dbf2a80f2df3d7 12:37
โ Running [before]:
โ Completed [before].
Running: test
โ Running [beforeEach]:
โ Completed [beforeEach].
โ Running command: windowSize ('current', [Function])
Request GET /session/6e3cf3d0e7109d6e37dbf2a80f2df3d7/window/current/size
Response 200 GET /session/6e3cf3d0e7109d6e37dbf2a80f2df3d7/window/current/size (2010ms)
{
sessionId: '6e3cf3d0e7109d6e37dbf2a80f2df3d7',
status: 0,
value: { height: 600, width: 800 }
}
{ height: 600, width: 800 }
โ Completed command: windowSize ('current', [Function]) (2018ms)
โ Running [afterEach]:
โ Completed [afterEach].
No assertions ran.
โ Running [after]:
โ Completed [after].
โ Running command: end ([Function])
โ Running command: session ('delete', [Function])
Request DELETE /session/6e3cf3d0e7109d6e37dbf2a80f2df3d7
Response 200 DELETE /session/6e3cf3d0e7109d6e37dbf2a80f2df3d7 (22ms)
{
sessionId: '6e3cf3d0e7109d6e37dbf2a80f2df3d7',
status: 0,
value: null
}
โ Completed command: end ([Function]) (33ms)
โ Completed command: session ('delete', [Function]) (30ms)
Wrote report file to: tests\output\src\CHROME_81.0.4044.138_Windows_test.xml.
Wrote log file to: D:\Denis\viewmaterializerapp\chromedriver.log.
ChromeDriver process closed.
We need verbose logs as well, in this case the chromedriver log also. It might also be a limitation of chromedriver headless mode implementation. Have you tried the same with Firefox?
2 log files are attached.
nightwatch.log
chromedriver.log
As I understand Firefox doesn't support "start-maximized" or "start-fullscreen" or something similar. If so, then I can't test this with Firefox. Or maybe you can explain how to do this with Firefox?
Could you post the logs inline please, as per contributing guidelines?
Edited first message by adding logs inline. Please, check.
Adding the argument --window-size=1920,1080 when running in headless mode is a work-around worth considering.
https://github.com/SeleniumHQ/selenium/issues/7476#issuecomment-519424923
https://github.com/SeleniumHQ/selenium/issues/7476#issuecomment-519938952
Based on the above GitHub discussions, it looks like chromeOptions is only recognized in Chrome driver versions earlier than Chrome 75, so we need to update to use the goog: prefix to properly pass in arguments.
Try this (irrelevant config was left out, but you get the idea)
{
"test_settings": {
"default": {
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"w3c": false,
"args": [
"disable-gpu",
"headless",
"window-size=1920,1080",
"disable-dev-shm-usage"
]
}
}
}
}
}
This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
Most helpful comment
Try this (irrelevant config was left out, but you get the idea)