Comments (14)
and expose all of what's in https://github.com/GoogleChrome/puppeteer/blob/master/lib/Connection.js ?
i was thinking maybe..
const connection = page.connection();
// send()
const ltree = await connection.send('LayerTree.getLayerTree');
// listen to events
await connection.send('LayerTree.enable');
connection.on('LayerTree.layerTreeChanged', data => { ... });
from puppeteer.
How will it be solved a problem with enabling some services? Currently, there are some services enabled in source code: https://github.com/GoogleChrome/puppeteer/blob/16320b7ac2943aa04420c67e9df367e7801409ea/lib/Page.js#L47-L50
So currently using page._client.send()
technique it's hard to know when to use page._client.send('XYZ.enable')
. For example:
// this will work without sending enable
await page._client.send('Network.clearBrowserCache');
// this one require sending enable
await page._client.send('ServiceWorker.enable');
await page._client.send('ServiceWorker.unregister', {
scopeURL: 'http://localhost:8080/',
});
Is page.connection()
will cover this problem? Or it will be in documentation when to send enable
?
from puppeteer.
Currently accessing the raw protocol via page._client like so:
await page._client.send('Log.enable');
page._client.on('Log.entryAdded', console.log);
But the proposed page.connection() sounds like a better solution :)
from puppeteer.
@ebidel we're working on it!
from puppeteer.
So having just:
var connection = page.connection()
should satisfy the usecase.
from puppeteer.
Here's a good usecase of why we need to punch through to raw protocol: gr2m/headless-chrome-test#1 Dev wants to toggle offline mode but is currently using simple-headless-chrome
from puppeteer.
@paulirish It seems to be a good idea to have offline mode in puppeteer to ease service worker testing, filed #63
from puppeteer.
Another use case is using the 'Network.setBlockedURLs` API. I run a crawler with an adblock list that blocks all ads; it would be much simpler to use that instead of using the intercept API and building a regex check for each of my adblock patterns.
from puppeteer.
Anyone working on this? Getting some requests that folks want to go off road. I'd love to recommend a paved path rather than a dirt road :)
from puppeteer.
Ping again :)
from puppeteer.
Can I help here?
from puppeteer.
Would be good to have for speed testing as well.
Accessing the time every element was loaded would be very useful.
from puppeteer.
Since I could also use this feature, I've opened a PR to implement this: #1445.
from puppeteer.
@Everettss Does enabling something twice do anything bad? It could be just best practice to enable something in your application if you want to use it.
I kind of see the problem here. Basically, puppeteer is high-level enough that it needs to keep an internal state, and sending messages via the raw protocol can break that state.
On the other hand, in JavaScript things breaking is just part of life. Raw protocol access should be something that is outlined as dangerous so people will be wary of it and that it can break internal state, but people should still be able to use it because puppeteer will never be able to implement all the functionality of the raw protocol. And if they break something, well, that's what debugging is for.
(From my perspective, using underscored members is not so much dangerous as not a feature of the library so don't use it).
Otherwise, programmers will have to use another library to send raw protocol messages, which will make the likelihood of breaking even higher.
from puppeteer.
Related Issues (20)
- Node process is hanging after all bidi tests are finished HOT 1
- AWS lambda: running puppeteer-core 21.5.2 and @sparticuz/chromium 118.0.0 on node 18 runtime failes ONLY when my html (for PDF rendering) contains https HOT 1
- [Bug]: the parameter outline in page.pdf seems not work HOT 6
- [Bug]: PDF page numbers no longer working in headless: shell HOT 3
- [Bug]: Install error HOT 2
- [Bug]: After deployment on server the service crashes for 5-10 concurrent users. HOT 2
- Chrome Canary test results HOT 27
- [Bug]: HOT 1
- [Bug]: HOT 7
- [Feature]: Add ability to exclude web sockets from WaitForNetworkIdle HOT 1
- Error: Passed function cannot be serialized! HOT 5
- [Bug]: Navigation failed because browser has disconnected! HOT 2
- Test "[click.spec] Page.click should click the button with fixed position inside an iframe" is flaky
- [Bug]: Failed to launch browser process. HOT 2
- Failed to launch the browser process! on WSL but working on local HOT 2
- HTTPRequest is checking for chrome-only error message "Invalid header" HOT 2
- [Typo] Docs have a misspelling in arhicture HOT 1
- [Bug]: Pages within the electron project cannot be connected HOT 8
- [Feature]: when I want to generate a pdf with 2 per sheet each, I don't find the corresponding api in "page.pdf (options?: PDFOptions)".
- [Feature]: Track the originator of http request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puppeteer.