You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] Why is 'setDownloadBehavior' required for connect_over_cdp? Any workaround? #30383
Sorry to bother here with a question. I added the same question in Discord but after a week, noone has answered so I'm trying luck here. Sorry for the spam.
I'm working on developing tests E2E for a web desktop application that uses Qt as its base for UI. The Qt version we are deploying uses Chromium v108.0.5359.71 as browser and we've successfully developed tests using ChromeDriver+Selenium but we are interested on transitioning to Playwright.
The issue we are having, also stated in the following comment in Github (#10927 (comment)) is that for some reason we aren't able to connect over CDP because the 'Browser.setDownloadBehavior' request is failing (file node_modules/playwright-core/lib/server/chromium/crBrowser.js -> _initialize function)
I enter this condition because our browser seems to have this._options.acceptDownloads = 'accept'. Before, if you see the comment linked above, the only restrictions were electron and clank.
If I comment this CDP request, Playwright is able to connect and my tests work as expected.
So, my question would be why is this a requirement and if anyone knows any workaround / a way to set Chromium browser's "acceptDownloads" option to the expected value "internal-browser-default" so I can overpass this?
Max Schmitt (@mxschmitt) My apologies for the late response, the project got delayed due to other priorities.
It still keeps not working for me... I've added this line process.env.PW_CHROMIUM_ATTACH_TO_OTHER = '1'; after the import and launched the chromium browser with both "--enable-chrome-runtime" and "--use-views" flags (also together) as suggested in the comments in here but nothing seems to work.
I keep receiving the same error message:
Error: browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported.
Call log:
- <ws preparing> retrieving websocket url from http://localhost:9222
- <ws connecting> ws://localhost:9222/devtools/browser/5d138cbc-fef3-459a-9950-e0535e27b1f6
- <ws connected> ws://localhost:9222/devtools/browser/5d138cbc-fef3-459a-9950-e0535e27b1f6
I leave my code here in case you spot anything weird:
import { test as base } from '@playwright/test';
const qa_check = process.env.QA_BUILD;
process.env.PW_CHROMIUM_ATTACH_TO_OTHER = '1';
function getFixture() {
let test;
if (qa_check !== undefined) {
test = base.extend({
browser: async ({ playwright }, use) => {
const browser = await playwright.chromium.connectOverCDP("http://localhost:9222"); # Failing here
await use(browser);
await browser.close();
},
context: async ({ browser }, use) => {
const context = browser.contexts()[0];
await use(context);
},
page: async ({ context }, use) => {
const page = context.pages()[0];
await use(page);
},
});
} else {
test = base;
}
return test;
}
export const test = getFixture();
I also do not know what "CEF Alloy mode" is to me honest, netiher how I could give you more info on my situation. Might be my Chromium version? Maybe it's too "old" for these features though the flags are been accepted by the broswer (no error was raised) but it's definetly not working :(
LFMM (@LFMM-33) CEF can be launched in two modes. Alloy which is deprecated and gets removed from CEF soon and native Chrome mode. The native Chrome mode. Depending on your implementation, it might be --enable-chrome-runtime or CefSettings.chrome_runtime = true.
Any indication / any check that could confirm if "Chrome runtime" is indeed enabled?
Anything I could check in the Devtools? Just looking to get more info.
Activity
mxschmitt commentedon Apr 18, 2024
Filed upstream bug: chromiumembedded/cef#3684
Filed upstream PR: https://bitbucket.org/chromiumembedded/cef/pull-requests/748
dgozman commentedon Apr 23, 2024
Closing in favor of chromiumembedded/cef#3684, since there is no action item on Playwright side.
mxschmitt commentedon Apr 24, 2024
LFMM (@LFMM-33) would that work for you? chromiumembedded/cef#3684 (comment)
Since the CEF Alloy mode is deprecated and gets removed soon the solution above seems to work as of today.
LFMM-33 commentedon May 30, 2024
Good morning,
Max Schmitt (@mxschmitt) My apologies for the late response, the project got delayed due to other priorities.
It still keeps not working for me... I've added this line
process.env.PW_CHROMIUM_ATTACH_TO_OTHER = '1';after the import and launched the chromium browser with both "--enable-chrome-runtime" and "--use-views" flags (also together) as suggested in the comments in here but nothing seems to work.I keep receiving the same error message:
I leave my code here in case you spot anything weird:
I also do not know what "CEF Alloy mode" is to me honest, netiher how I could give you more info on my situation. Might be my Chromium version? Maybe it's too "old" for these features though the flags are been accepted by the broswer (no error was raised) but it's definetly not working :(
mxschmitt commentedon May 30, 2024
LFMM (@LFMM-33) CEF can be launched in two modes. Alloy which is deprecated and gets removed from CEF soon and native Chrome mode. The native Chrome mode. Depending on your implementation, it might be
--enable-chrome-runtimeorCefSettings.chrome_runtime = true.And yes, it requires a recent CEF I think.
LFMM-33 commentedon May 30, 2024
Max Schmitt (@mxschmitt) Thank you for the clarification. I'll look into it with a C++ dev.
Any indication / any check that could confirm if "Chrome runtime" is indeed enabled?
Anything I could check in the Devtools? Just looking to get more info.
mxschmitt commentedon May 30, 2024
I'm unfortunately not very familiar with CEF, this might be helpful: chromiumembedded/cef#3685