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

Method current_url

src/cdp.rs:814–831  ·  view source on GitHub ↗

Get the current page URL via JavaScript evaluation.

(&mut self, session_id: &str)

Source from the content-addressed store, hash-verified

812
813 /// Get the current page URL via JavaScript evaluation.
814 pub async fn current_url(&mut self, session_id: &str) -> Result<String> {
815 let result = self
816 .send_to_target(
817 session_id,
818 "Runtime.evaluate",
819 json!({"expression": "window.location.href", "returnByValue": true}),
820 )
821 .await?;
822 result["result"]["value"]
823 .as_str()
824 .map(|s| s.to_string())
825 .ok_or_else(|| {
826 anyhow!(
827 "Failed to get current URL: evaluation did not return a string. Result: {}",
828 result
829 )
830 })
831 }
832
833 /// Resolve which page to operate on.
834 /// Priority: --target (by ID or friendly name) > --page (by index) > first page.

Callers 10

clickFunction · 0.80
click_atFunction · 0.80
hoverFunction · 0.80
fillFunction · 0.80
type_textFunction · 0.80
press_keyFunction · 0.80
do_reloadFunction · 0.80
evaluateFunction · 0.80
run_scriptFunction · 0.80
run_adapterFunction · 0.80

Calls 1

send_to_targetMethod · 0.80

Tested by

no test coverage detected