Comments (7)
Can you check whether the eventlistener api I introduced in #4 fulfills your needs.
This is currently only exposed on the Page
, but could potentially also added to the browser itself.
I double checked and I see a couple of problems with emitting events from the Browser
, right now the Target
s emit the events where the message contains the sessionId
of the Target
.
Emitting events from the browser that don't contain a sessionId
should be rather easy to implement though.
from chromiumoxide.
That looks like something like that would work. I'm assuming it would look something like this:
let target = browser.event_listener::<EventTargetCreated>().await?;
We must send setDiscoverTargets before targets are created though:
Which I guess would look something like this:
browser.execute::<SetDiscoverTargetsParams>();
Edit: It appears that setDiscoverTargets
is already being sent to CDP. Though I don't know by which function.
from chromiumoxide.
It appears that setDiscoverTargets is already being sent to CDP. Though I don't know by which function.
Yes this is the very first command sent when creating the Handler
The drawback from exposing the event_listner
on the browser directly is that there aren't many events that aren't related to a session, so it would not be very easy to distinguish what event should be sent via the browser's event pipeline or via the target's event pipeline.
One thing that may be possible is to emit all events of a certain type on the Browser
disregarding the event's sessionId
and only emitting the event via the Target
with the matching sessionId
(as it is right now). However this would introduce a certain overhead (wrapping all events in Arc
or cloning a lot), this might do more harm than it is useful
from chromiumoxide.
The drawback from exposing the
event_listner
on the browser directly is that there aren't many events that aren't related to a session, so it would not be very easy to distinguish what event should be sent via the browser's event pipeline or via the target's event pipeline.
One thing that may be possible is to emit all events of a certain type on theBrowser
disregarding the event'ssessionId
and only emitting the event via theTarget
with the matchingsessionId
(as it is right now). However this would introduce a certain overhead (wrapping all events inArc
or cloning a lot), this might do more harm than it is useful
I agree I was just about to suggest something like a custom_on_target_created
('target_changed
, 'destroyed
etc.) in the handler would make more sense.
See my use case is running operations and each page. So maybe I just need those functions to return a Page for me to call execute
, evaluate
etc. on.
Edit: Actually, I'll investigate using Browser.pages() for this.
from chromiumoxide.
I see, does Browser::pages
fulfil your needs?
from chromiumoxide.
It might. I'm not sure yet. I'll check it out though.
from chromiumoxide.
Browser::pages seems to only return a vector of pages. I need to run operations on every page that exists (when they exist). If I run it early and a page gets added later I won't know until the next time I run pages(). Also, I only want to run these operations once per added page or navigation.
from chromiumoxide.
Related Issues (20)
- How to download picture like downloading other file types? HOT 8
- Detect more browsers HOT 3
- Set language to english HOT 5
- How to wait for lifecycle events HOT 1
- Respond to intercepted request
- Github actions tests websocket closing
- Better error reporting for browser start errors
- Goto never returns if first request is aborted
- Add some automated tests
- Fetcher default browser stuck in Windows 10 HOT 4
- Drop of browser causes panic HOT 2
- Close does not work HOT 1
- release new version plz HOT 1
- How to find an element that contains some text?
- How to do basic authentication for proxy?
- Use request intercept with connect() on an existing Chromium instance HOT 1
- browser.pages() does not return pages that weren't created directly by the crate but that are visible in CDP HOT 2
- Browser close() failure HOT 1
- Where would be the best place to pass an api key as basic auth to the page in which you are loading?
- Docker Failure to Compile chromiumoxide_cdp HOT 2
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 chromiumoxide.