Giter Club home page Giter Club logo

Comments (7)

mattsse avatar mattsse commented on June 12, 2024

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 Targets 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.

bobajeff avatar bobajeff commented on June 12, 2024

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.

mattsse avatar mattsse commented on June 12, 2024

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.

bobajeff avatar bobajeff commented on June 12, 2024

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

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.

mattsse avatar mattsse commented on June 12, 2024

I see, does Browser::pages fulfil your needs?

from chromiumoxide.

bobajeff avatar bobajeff commented on June 12, 2024

It might. I'm not sure yet. I'll check it out though.

from chromiumoxide.

bobajeff avatar bobajeff commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.