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

Method get_page_targets

src/cdp.rs:662–688  ·  view source on GitHub ↗

List all open page targets.

(&mut self)

Source from the content-addressed store, hash-verified

660
661 /// List all open page targets.
662 pub async fn get_page_targets(&mut self) -> Result<Vec<TargetInfo>> {
663 let result = self.send("Target.getTargets", json!({})).await?;
664 let targets = result["targetInfos"].as_array().ok_or_else(|| {
665 anyhow!("Malformed Target.getTargets response: missing 'targetInfos' array")
666 })?;
667
668 let mut pages = Vec::new();
669 for t in targets {
670 let target_type = t["type"].as_str().unwrap_or("");
671 if target_type == "page" {
672 let target_id = t["targetId"]
673 .as_str()
674 .ok_or_else(|| anyhow!("Malformed TargetInfo: missing 'targetId'"))?
675 .to_string();
676 let title = t["title"].as_str().unwrap_or("").to_string();
677 let url = t["url"].as_str().unwrap_or("").to_string();
678
679 pages.push(TargetInfo {
680 target_id,
681 title,
682 url,
683 target_type: target_type.to_string(),
684 });
685 }
686 }
687 Ok(pages)
688 }
689
690 /// List all targets (pages, workers, etc.).
691 pub async fn get_all_targets(&mut self) -> Result<Vec<TargetInfo>> {

Callers 2

resolve_pageMethod · 0.80
list_pagesFunction · 0.80

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected