Playwright Firefox blockRequests: CDP session is only available in Chromium
See original GitHub issueWhich 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:
- Created a year ago
- Comments:10 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 😕@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).