INNER CODE UNIT · Rust
attach_page_light
keon/browser-control · src/cdp.rs:139
pub async fn attach_page_light(&mut self, target: Option<String>) -> Result<()> {
let id = if let Some(t) = target {
t
} else {
match self.first_tab().await? {
Some(id) => id,
None => self
.send("Target.createTarget", json!({"url":"about:blank"}), None)
.await?["targetId"]
.as_str()
.context("targetId")?
.into(),
}
};
let r = self
.send(
"Target.attachToTarget",
json!({"targetId":id,"flatten":true}),