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)
- [Bug]: Stuck at puppeteer.connect() HOT 2
- [Bug]: Even your example code is not working - SyntaxError: Cannot use import statement outside a module HOT 1
- [Feature]: Inserting a Audio and video Stream
- "[network.spec] network Page.authenticate should work" test is flaky HOT 1
- [Bug]: Browser gets disconnected in Docker without any errors HOT 28
- [Bug]: Failed to launch the browser process!\nchrome_crashpad_handler: --database is required HOT 2
- Docs: the index page for docs should not be a readme.md
- [Feature]: Accessing WebRTC peerConnection in puppeteer
- Force pushing to default branch HOT 1
- [Bug]: ERROR in DIGITALOCEAN APPLICATION PLATFORM HOT 2
- [Bug]: when accessing browser.targets() I don't get info about _targetInfo which have property like _targetInfo.title , _targetInfo.type... HOT 2
- [Bug]: Opening the extension popup.html using will return new empty popup without any data how to get popup.html within the context of a specific tab/website HOT 4
- [Bug]: Background is pink when using background: repeating-linear-gradient HOT 10
- [Bug]: Could not able to get the selectors when headless: true, but it is working with headless:false HOT 1
- [Bug]: Freezing when querying frames on certain websites HOT 11
- [Feature]: `Mouse.dragAndDrop` API not supported for WebDriver BiDi HOT 7
- Error: Attempted to use detached Frame HOT 15
- [Bug]: spawn ENAMETOOLONG HOT 8
- [Bug]: element disappears when cross the bound of the PDF footer HOT 5
- [Bug] puppeteer.launch with cmd file cause spawn EINVAL with recent node security patch HOT 7
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.