Tests do not start with Chrome and Edge with version 110 and above with --headless flag
ankur-lt opened this issue · comments
Describe the bug
I am launching Chrome browser and passing its WS URL in the target. Refer the taiko plugin: https://www.npmjs.com/package/taiko-lambdatest
When launching Chrome >= 110 with the ALI arg --headed
, the chrome-remote-interface keeps on calling the /json/protocol
API when though the response is 200.
Command used:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --headless
I compared the response of the API GET /json/protocol
for Chrome with headed and headless mode, but the response was the same.
The library keeps on calling GET /json/protocol
even though the response is valid and thus doesn't start the test.
To Reproduce
Steps (or script) to reproduce the behavior in local:
- Start Chrome with command
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --headless
on MacOS or on other OS with appropriate path. - Add the WS URL of Chrome as the target in
openBrowser()
function. - Run the test.
/* globals gauge*/
"use strict";
const path = require('path');
const { openBrowser, closeBrowser } = require('taiko');
beforeScenario(async() => {
await openBrowser({
target: "ws://127.0.0.1:9222/devtools/browser/acc40aca-0c93-44f9-aed8-8410aa9f645c"
});
});
afterScenario(async (context) => {
await closeBrowser();
});
Expected behavior
The test should launch and get executed.
Versions:
- Taiko: 1.3.4
- OS: MacOS Ventura 13.3.1
- Node.js: v14.20.0
gauge -v
Gauge version: 1.4.3
Commit Hash: f98dd40
Plugins
-------
html-report (4.1.2)
js (2.3.17)
screenshot (0.1.0)
Additional context
I am trying to launch the browser with the provided CLI args and then pass the WS URL in the target.
I add previously raised this PR: #2380 to add support of running taiko tests on remote machines.
The above code I have added is to reproduce the scenario in local.
It works as expected with headed mode on all chrome versions. Its giving the above issue for chrome and edge >=110.
When I tried setting TAIKO_BROWSER_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
start the test with the below openBrowser()
function:
await openBrowser({
headless: true
})
the test works as expected. Although, I am not being able to check the CLI args passed by taiko in this case as chrome://version
isn't allowed in headless mode.
The following WS message is received from browser in case of headless browser, which thus leads to a retry.
"{\"id\":1,\"result\":{\"targetInfos\":[]}}"
@zabil , @saikrishna321 , can you check this?
The first CDP command send to browser is:
{"id":1,"method":"Target.getTargets","params":{}}
Shouldn't we first create target using {"method":"Target.createTarget","params":{"url":"about:blank"},"id":5}
, the way Puppeteer does it and then send the Target.getTargets
message?
Although, as per I checked, the targets are already created for Chrome <110 without having to explicitly create targets.
Yes taiko tries to use the existing tab, may be the behaviour is changed now with the latest version of the browser. We will have to revisit this.