Coder Social home page Coder Social logo

Comments (4)

stevepryde avatar stevepryde commented on July 21, 2024

Weird, I had not heard of this command until now. I don't think it is part of the WebDriver spec at all but it seems to use the same W3C protocol to execute the commands.

It shouldn't be too difficult to implement this, going by the python code for it.

from thirtyfour.

stevepryde avatar stevepryde commented on July 21, 2024

Turns out this will require a refactor of some core layers to remove lifetimes from Command and allow for commands outside the core W3C spec to be passed through. I've started this work on the command-refactor branch (heads up in case anyone is following this issue).

I'm thinking this might need to be its own function or struct, rather than a method on WebDriver since it only applies to Chromium-based browsers. It would likely borrow the session and execute the command that way.

from thirtyfour.

stevepryde avatar stevepryde commented on July 21, 2024

@guoyucode I've added initial support for the Chrome Devtools Protocol (CDP) on the cdp branch.

You can use it as follows:

let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new("http://localhost:4444", &caps).await?;

// Use Chrome Devtools Protocol (CDP).
let dev_tools = ChromeDevTools::new(driver.session());
let mut conditions = NetworkConditions::new();
conditions.download_throughput = 20;
conditions.upload_throughput = 10;
dev_tools.set_network_conditions(&conditions).await?;
let conditions = dev_tools.get_network_conditions().await?;
assert_eq!(conditions.download_throughput, 20);
assert_eq!(conditions.upload_throughput, 10);
println!("Conditions: {:?}", conditions);

// Execute CDP command.
let version_info = dev_tools.execute_cdp("Browser.getVersion").await?;
println!("Chrome Version: {:?}", version_info["product"].as_str());

You can also specify parameters with dev_tools.execute_cdp_with_params() where the second parameter is a serde_json::Value containing any arguments you want to supply. This allows sending arbitrary args with any command.

Let me know what you think. I have not tested all of the functionality and probably won't be able to.

from thirtyfour.

stevepryde avatar stevepryde commented on July 21, 2024

This has now been added in v0.20.0. Please open a new issue if you need anything further.

from thirtyfour.

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.