question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Playwright Firefox blockRequests: CDP session is only available in Chromium

See original GitHub issue

Which package is this bug report for? If unsure which one to select, leave blank

@crawlee/playwright (PlaywrightCrawler)

Issue description

I would like to use Playwright with Firefox and use blockRequests. However, it seems to be working with Chromium only because I get the following error messages:

browserContext.newCDPSession: CDP session is only available in Chromium

If I remove the preNavigationHooks, I don’t get the error. In the documentation there is no mention of it being exclusive to Chromium. Is it?

Code sample

launchContext: {
        launcher: firefox
    },
    preNavigationHooks: [
        async ({blockRequests}) => {
            await blockRequests({
                urlPatterns: ['google.com']
            })
        }
    ]


### Package version

^3.0.0

### Node.js version

v19.0.0

### Operating system

Ubuntu

### Apify platform

- [ ] Tick me if you encountered this issue on the Apify platform

### Priority this issue should have

Medium (should be fixed soon)

### I have tested this on the `next` release

_No response_

### Other context

_No response_

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
barjincommented, Nov 4, 2022

well, from 3.1.1 on, it will print a warning message (while using Firefox/Webkit) and won’t fail completely. This means, you’ll be able to switch between browsers in your code (and they will all work, plug-and-play style), but Firefox still won’t block any requests.

If you need to block certain requests with Firefox, you can always use Playwright’s native page.route() with appropriate handlers - this will disable browser cache and might lead to some performance issues, though 😕

1reaction
AndreyBykovcommented, Nov 4, 2022

@galaczi It’s currently available in beta. Would be at latest with the next minor release (i.e. should be available in 3.1.1).

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] Regarding CDP Session. · Issue #2484 - GitHub
I am converting all my puppeteer code which used to look like this.
Read more >
Web Scraping: How to Block Resources in Playwright
Learn how to block stylesheets, images, videos, scripts, and other resources to save bandwidth and fasten your scrapers.
Read more >
Launch Browser | playwright-ruby-client
In oder to launch browser, it is required to create Playwright session. ... Chromium; playwright.firefox.launch for launching (modified version of) Firefox ...
Read more >
Blocking Resources with Playwright - DevPress - CSDN
Did you know that Playwright allows you to block requests and thus speed ... Playwright "is a Python library to automate Chromium, Firefox, ......
Read more >
Set browser options for Playwright tests | BrowserStack Docs
Playwright allows you to set browser arguments for Chromium based browsers and Firefox user preferences if the selected browser is Firefox. These arguments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found