MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / get_all_targets

Method get_all_targets

src/cdp.rs:691–710  ·  view source on GitHub ↗

List all targets (pages, workers, etc.).

(&mut self)

Source from the content-addressed store, hash-verified

689
690 /// List all targets (pages, workers, etc.).
691 pub async fn get_all_targets(&mut self) -> Result<Vec<TargetInfo>> {
692 let result = self.send("Target.getTargets", json!({})).await?;
693 let targets = result["targetInfos"].as_array().ok_or_else(|| {
694 anyhow!("Malformed Target.getTargets response: missing 'targetInfos' array")
695 })?;
696
697 let mut all = Vec::new();
698 for t in targets {
699 all.push(TargetInfo {
700 target_id: t["targetId"]
701 .as_str()
702 .ok_or_else(|| anyhow!("Malformed TargetInfo: missing 'targetId'"))?
703 .to_string(),
704 title: t["title"].as_str().unwrap_or("").to_string(),
705 url: t["url"].as_str().unwrap_or("").to_string(),
706 target_type: t["type"].as_str().unwrap_or("").to_string(),
707 });
708 }
709 Ok(all)
710 }
711
712 /// Attach to a target and return the session ID for subsequent commands.
713 pub async fn attach_to_target(&mut self, target_id: &str) -> Result<String> {

Callers 1

collect_sw_logsFunction · 0.80

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected