GithubHelp home page GithubHelp logo

Comments (3)

HMaker avatar HMaker commented on May 31, 2024

What would be the use case for that?

The CDP command types have the to_json() method to serialize it to be sent to the chrome browser (on-wire format). The JSON structure matches the defined ones by the CDP protocol specification.

The CDP events are just received by the client, they are never sent to the chrome browser (server). That's why there is no to_json() implemented for them.

from python-cdp.

RazorBest avatar RazorBest commented on May 31, 2024

I understand that, but my use case is a little different. I have a program that uses python-cdp to listen to CDP events, and I want to add functional tests. So, I chose my tests to have as input, CDP events in JSON format, as close as possible to what chrome would give. I don't know a way to access the JSON objects directly, so I chose the following solution: get the CDP events converted to Python objects, as python-cdp does, then convert them back to JSON using the to_json methods.

from python-cdp.

HMaker avatar HMaker commented on May 31, 2024

You want to inject fake CDP events and test your listener behavior? Can't you just inject plain JSON objects and let pycdp parse it?

Instead you can make the function which handles CDP events take them as argument, the Python wrapper types. Then you can call it directly from the test.

Anyway feel free to make a PR, I will review it. Make the to_json() follow the same syntax and semantic of CDP.

from python-cdp.

Related Issues (7)

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.