Skip to content

[Feature] Allow connecting to CEF instances via browserType.connectOverCDP #10927

Closed

Description

@rajukshetri

Context:

  • Playwright Version: [Version 1.17.1]
  • Operating System: [Windows]
  • Node.js version: [v12.16.1]
  • Browser: [ CEF | 90.6.3+gc53c523+chromium-90.0.4430.93]
  • Extra:
  • CEF | 90.6.3+gc53c523+chromium-90.0.4430.93
    Chromium | 90.0.4430.93
    OS | Windows
    WebKit | 537.36 (@4df112c29cfe9a2c69b14195c0275faed4e997a7)
    JavaScript | 9.0.257.23
    User Agent | Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93; ) Safari/537.36

Code Snippet
import { test, expect ,chromium } from '@playwright/test';
test('my test', async () => {
const cdpBrowser1 = await chromium.connectOverCDP({
wsEndpoint: ws://localhost:9222/devtools/browser/01582b7e-7cb0-4bed-a8b1-5e211d3a3ab6,
});
});

Describe the bug

I have an application that uses the chromium version 90 from CEF as a browser .
when I run the above snippet it throws the following exception:
browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported.
=========================== logs ===========================
ws://localhost:9222/devtools/browser/01582b7e-7cb0-4bed-a8b1-5e211d3a3ab6
ws://localhost:9222/devtools/browser/01582b7e-7cb0-4bed-a8b1-5e211d3a3ab6
============================================================

6 | const cdpBrowser1 = await chromium.connectOverCDP({
^
7 | wsEndpoint: ws://localhost:9222/devtools/browser/01582b7e-7cb0-4bed-a8b1-5e211d3a3ab6,
8 | });
9 | console.log('connected ');

    at D:\projects\playwright\tests\demo.spec.ts:6:39
    at FixtureRunner.resolveParametersAndRunHookOrTest (D:\projects\\playwright\node_modules\@playwright\test\lib\fixtures.js:306:12)
    at WorkerRunner._runTestWithBeforeHooks (D:\projects\playwright\node_modules\@playwright\test\lib\workerRunner.js:499:7)

same snippet works fine for the chromium browser 90 when it launched via:
"C:\Users\rakshetri\AppData\Local\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9333 -- "%1"

Activity

  1. mxschmitt commented on Dec 15, 2021

    @mxschmitt
  2. mxschmitt commented on Dec 15, 2021

    @mxschmitt
  3. rajukshetri commented on Dec 16, 2021

    @rajukshetri
    Author

    Max Schmitt (@mxschmitt) As we are using CEF :https://en.wikipedia.org/wiki/Chromium_Embedded_Framework that uses the embedded chromium to our application and we do not upgrade it so frequently.
    Is there any way to use the older library of playwright that support the respective chromium browser .
    Is there any workaround or customization to get rid of this issue ?
    We already using selenium for such requirement and achieved this with maintaining chromedriver.exe of respective version of chrome.
    And we are evaluating playwright as a new tool for replacement of selenium .

    Closing since Playwright does not support old Chromium browsers.

  4. rajukshetri commented on Dec 16, 2021

    @rajukshetri
    Author

    Max Schmitt (@mxschmitt)
    I have tried with CEF that embedded chromium "Browser": "Chrome/94.0.4606.61", but issue is same .
    Unfortunately we don't have product released with CEF which have chrome 96 , but I think this issue is not related to the browser version since same PW configuration works for the standalone browser chrome version 90 installed at machine.

  5. mxschmitt commented on Dec 16, 2021

    @mxschmitt
    Contributor

    Playwright does not support connecting to CEF instances as of today, since CEF does not expose the Browser.* CDP domain. Will create a feature request out of it.

  6. changed the title [-][BUG] browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported.[/-] [+][Feature] Allow connecting to CEF instances via `browserType.connectOverCDP`[/+] on Dec 16, 2021
  7. rajukshetri commented on Dec 17, 2021

    @rajukshetri
    Author

    Max Schmitt (@mxschmitt) thank you very much I will be highly appreciate your efforts towards this .
    I am eagerly waiting for this support as this is road blocking for our CEF e2e testing with PW.

  8. shals-praise commented on Jan 11, 2022

    @shals-praise

    Max Schmitt (@mxschmitt) I am evaluating playwright for our automation requirements and so far it seems to be a great e2e testing framework!!..We also need this feature to connect to CEF. Most of the latest testing frameworks do support Chromium Embedded Framework... Waiting to have it supported by playwright soon.!!

  9. mxschmitt commented on Jan 13, 2022

    @mxschmitt
    Contributor

    rajukshetri shals-praise please upvote the first comment - thats the way we prioritise feature requests.

  10. collin-rogers commented on Mar 21, 2022

    @collin-rogers

    Max Schmitt (@mxschmitt) I am also evaluating playwright for our current automation requirements. I've been using puppeteer as a temporary solution for our CEF e2e testing, but I would love to be able to use the features of playwright. Hoping this feature comes soon!

  11. rprabhun commented on Mar 22, 2022

    @rprabhun

    Max Schmitt (@mxschmitt) I am also evaluating playwright for our current automation requirements. I've been using puppeteer as a temporary solution for our CEF e2e testing, but I would love to be able to use the features of playwright. Hoping this feature comes soon!

    collin-rogers please upvote the first comment - thats the way they prioritise feature requests.

  12. pavelfeldman commented on Oct 20, 2022

    @pavelfeldman
    Member

    This falls outside of the scope for Playwright, so if connectOverCDP does not work for you, there isn't much we can do. Make sure your CEF version matches the Chromium version Playwright is for.

  13. rebajz commented on May 4, 2023

    @rebajz

    How use playwright with CEF

    tested on playwright 1.33.0 and CEF 110

    start app with CEF browser
    visit http://localhost:XXXX/json/version

    where XXXX is debug port

    you see something as:
    {
    "Browser": "Chrome/110.0.5481.178",
    "Protocol-Version": "1.3",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36",
    "V8-Version": "11.0.226.16",
    "WebKit-Version": "537.36 (@e9acac08b3d8368c80ef92352d046e924969e9bf)",
    "webSocketDebuggerUrl": "ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e"
    }

    demo test file
    const {chromium} = require('playwright');

    test('demo test', async () => {
    const browser = await chromium.connectOverCDP(
    'here copy webSocketDebuggerUrl from json'
    );
    const defaultContext = browser.contexts()[0];
    const myPage = defaultContext.pages()[0];
    await myPage.goto('https://playwright.dev/');
    });

    When you run this test, you get error something as:
    Error: browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported.
    =========================== logs ===========================
    ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e
    ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e

    But, when you do this change in source of playwright:
    node_modules\playwright-core\lib\server\chromium\crBrowser.js

    lines 297 to 304 delete or do from lines only comments
    if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') {
    promises.push(this._browser._session.send('Browser.setDownloadBehavior', {
    behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny',
    browserContextId: this._browserContextId,
    downloadPath: this._browser.options.downloadsPath,
    eventsEnabled: true
    }));
    }

    after change:
    // if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') {
    // promises.push(this._browser._session.send('Browser.setDownloadBehavior', {
    // behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny',
    // browserContextId: this._browserContextId,
    // downloadPath: this._browser.options.downloadsPath,
    // eventsEnabled: true
    // }));
    // }

    run playwright again... you see
    npx playwright test example.spec.ts

    Running 1 test using 1 worker
    1 passed (2.1s)

    :-) :-) :-)

    edit:
    when you use this in test, this working too

    const browser = await chromium.connectOverCDP({endpointURL: 'http://localhost:5555'});

  14. wkyseo commented on Jul 6, 2023

    @wkyseo

    How use playwright with CEF

    tested on playwright 1.33.0 and CEF 110

    start app with CEF browser visit http://localhost:XXXX/json/version

    where XXXX is debug port

    you see something as: { "Browser": "Chrome/110.0.5481.178", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", "V8-Version": "11.0.226.16", "WebKit-Version": "537.36 (@e9acac08b3d8368c80ef92352d046e924969e9bf)", "webSocketDebuggerUrl": "ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e" }

    demo test file const {chromium} = require('playwright');

    test('demo test', async () => { const browser = await chromium.connectOverCDP( 'here copy webSocketDebuggerUrl from json' ); const defaultContext = browser.contexts()[0]; const myPage = defaultContext.pages()[0]; await myPage.goto('https://playwright.dev/'); });

    When you run this test, you get error something as: Error: browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported. =========================== logs =========================== ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e

    But, when you do this change in source of playwright: node_modules\playwright-core\lib\server\chromium\crBrowser.js

    lines 297 to 304 delete or do from lines only comments if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { promises.push(this._browser._session.send('Browser.setDownloadBehavior', { behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', browserContextId: this._browserContextId, downloadPath: this._browser.options.downloadsPath, eventsEnabled: true })); }

    after change: // if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { // promises.push(this._browser._session.send('Browser.setDownloadBehavior', { // behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', // browserContextId: this._browserContextId, // downloadPath: this._browser.options.downloadsPath, // eventsEnabled: true // })); // }

    run playwright again... you see npx playwright test example.spec.ts

    Running 1 test using 1 worker 1 passed (2.1s)

    :-) :-) :-)

    edit: when you use this in test, this working too

    const browser = await chromium.connectOverCDP({endpointURL: 'http://localhost:5555'});

    rebajz image

  15. ovclara commented on Jul 11, 2023

    @ovclara

    Working on a project where many applications use CEF and CEF versions is not updated always, I wanted to propose - Playwright as a automation tool for this projects, but due to this complexity in connecting CEF seamlessly we are blocked to go ahead.
    I see a post on CEF forum : https://magpcss.org/ceforum/viewtopic.php?f=6&t=19313
    Where it seems CEF has no plans to expose Browser.* CPD domain, so we look at PlayWright team to have some easy way to handle this so that we could user this Awesome tool.

  16. AlanCodega commented on Jul 25, 2023

    @AlanCodega

    How use playwright with CEF
    tested on playwright 1.33.0 and CEF 110
    start app with CEF browser visit http://localhost:XXXX/json/version
    where XXXX is debug port
    you see something as: { "Browser": "Chrome/110.0.5481.178", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", "V8-Version": "11.0.226.16", "WebKit-Version": "537.36 (@e9acac08b3d8368c80ef92352d046e924969e9bf)", "webSocketDebuggerUrl": "ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e" }
    demo test file const {chromium} = require('playwright');
    test('demo test', async () => { const browser = await chromium.connectOverCDP( 'here copy webSocketDebuggerUrl from json' ); const defaultContext = browser.contexts()[0]; const myPage = defaultContext.pages()[0]; await myPage.goto('https://playwright.dev/'); });
    When you run this test, you get error something as: Error: browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported. =========================== logs =========================== ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e
    But, when you do this change in source of playwright: node_modules\playwright-core\lib\server\chromium\crBrowser.js
    lines 297 to 304 delete or do from lines only comments if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { promises.push(this._browser._session.send('Browser.setDownloadBehavior', { behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', browserContextId: this._browserContextId, downloadPath: this._browser.options.downloadsPath, eventsEnabled: true })); }
    after change: // if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { // promises.push(this._browser._session.send('Browser.setDownloadBehavior', { // behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', // browserContextId: this._browserContextId, // downloadPath: this._browser.options.downloadsPath, // eventsEnabled: true // })); // }
    run playwright again... you see npx playwright test example.spec.ts
    Running 1 test using 1 worker 1 passed (2.1s)
    :-) :-) :-)
    edit: when you use this in the test, this working too
    const browser = await chromium.connectOverCDP({endpointURL: 'http://localhost:5555'});

    For us, using cfsharp (CEF) browser, these hints solve our issue (comment the code suggested upper)

    But the demand for this functionality is still live as I can see from the different topics and threads around (not only here in GitHub playwright).
    Having this will allow us to switch from cypress to playwright.

  17. zotune commented on May 24, 2024

    @zotune

    How use playwright with CEF

    tested on playwright 1.33.0 and CEF 110

    start app with CEF browser visit http://localhost:XXXX/json/version

    where XXXX is debug port

    you see something as: { "Browser": "Chrome/110.0.5481.178", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", "V8-Version": "11.0.226.16", "WebKit-Version": "537.36 (@e9acac08b3d8368c80ef92352d046e924969e9bf)", "webSocketDebuggerUrl": "ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e" }

    demo test file const {chromium} = require('playwright');

    test('demo test', async () => { const browser = await chromium.connectOverCDP( 'here copy webSocketDebuggerUrl from json' ); const defaultContext = browser.contexts()[0]; const myPage = defaultContext.pages()[0]; await myPage.goto('https://playwright.dev/'); });

    When you run this test, you get error something as: Error: browserType.connectOverCDP: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported. =========================== logs =========================== ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e ws://localhost:5555/devtools/browser/22501224-0c07-4649-a8e1-3bc94dcddd0e

    But, when you do this change in source of playwright: node_modules\playwright-core\lib\server\chromium\crBrowser.js

    lines 297 to 304 delete or do from lines only comments if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { promises.push(this._browser._session.send('Browser.setDownloadBehavior', { behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', browserContextId: this._browserContextId, downloadPath: this._browser.options.downloadsPath, eventsEnabled: true })); }

    after change: // if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') { // promises.push(this._browser._session.send('Browser.setDownloadBehavior', { // behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny', // browserContextId: this._browserContextId, // downloadPath: this._browser.options.downloadsPath, // eventsEnabled: true // })); // }

    run playwright again... you see npx playwright test example.spec.ts

    Running 1 test using 1 worker 1 passed (2.1s)

    :-) :-) :-)

    edit: when you use this in test, this working too

    const browser = await chromium.connectOverCDP({endpointURL: 'http://localhost:5555'});

    Can confirm that this works for html CEF panels in Adobe Premiere. Thanks!

    Playwright team, could we possibly make it an option to disable setDownloadBehavior without having to comment out component code in node_modules?

    Given that adobe decides the chrome version and panel, this probably wont solve it for me (for a long time anyway): chromiumembedded/cef#3684

    A workaround might be if I could set browser.options.name to electron or something it should skip that part of the component code.

  18. huxiang commented on Mar 3, 2026

    @huxiang

    Cursor gives me a workaround by patching the crBrowser.js file in playwright module:

    PATCH_OLD = "if (this._browser.options.name !== 'clank' && this._options.acceptDownloads !== 'internal-browser-default') {"
    PATCH_NEW = "if (this._browser.options.name !== 'clank' && this._options.acceptDownloads !== 'internal-browser-default' && !process.env.PW_CHROMIUM_DISABLE_DOWNLOAD_BEHAVIOR) {"
    

    Before connecting to electron app via CDP, set env var PW_CHROMIUM_DISABLE_DOWNLOAD_BEHAVIOR=1, then it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions