INNER CODE UNIT · Rust
wheel
keon/browser-control · src/actions.rs:39
pub async fn wheel(c: &mut Cdp, x: i64, y: i64, dx: i64, dy: i64) -> Result<()> {
c.call(
"Input.dispatchMouseEvent",
json!({"type":"mouseWheel","x":x,"y":y,"deltaX":dx,"deltaY":dy}),
true,
)
.await?;
Ok(())
}
pub async fn element_center(c: &mut Cdp, target: &str) -> Result<(i64, i64)> {
let v = c
.eval(&format!(
"({ACTION_JS}).point({})",
serde_json::to_string(target)?
))
.await?;
let x = v["x"].as_i64().context("element x")?;