Create a new page target and return its target ID.
(&mut self, url: &str)
| 739 | |
| 740 | /// Create a new page target and return its target ID. |
| 741 | pub async fn create_target(&mut self, url: &str) -> Result<String> { |
| 742 | let result = self |
| 743 | .send("Target.createTarget", json!({"url": url})) |
| 744 | .await?; |
| 745 | result["targetId"] |
| 746 | .as_str() |
| 747 | .map(|s| s.to_string()) |
| 748 | .ok_or_else(|| anyhow!("No targetId in createTarget response")) |
| 749 | } |
| 750 | |
| 751 | /// Close a target by its target ID. |
| 752 | pub async fn close_target(&mut self, target_id: &str) -> Result<()> { |