pub struct OneShotSession { /* private fields */ }Expand description
Headless Chrome session owned by a single CLI invocation (or one run script).
Implementations§
Source§impl OneShotSession
impl OneShotSession
Sourcepub async fn launch_headless() -> Result<Self, CliError>
pub async fn launch_headless() -> Result<Self, CliError>
Launch local Chrome only (no connect, no daemon).
pub async fn launch_headless_with_capture( capture: CaptureOpts, ) -> Result<Self, CliError>
Sourcepub async fn launch_with_extensions(
capture: CaptureOpts,
extensions: Vec<String>,
) -> Result<Self, CliError>
pub async fn launch_with_extensions( capture: CaptureOpts, extensions: Vec<String>, ) -> Result<Self, CliError>
Launch with Chrome extensions loaded (--load-extension).
pub fn chrome_pid(&self) -> Option<u32>
pub fn capture(&self) -> CaptureOpts
Sourcepub fn with_capture_fields(&mut self, data: Value) -> Value
pub fn with_capture_fields(&mut self, data: Value) -> Value
Merge console/network buffers into a result JSON when capture flags are on.
Sourcepub fn drain_events(&mut self)
pub fn drain_events(&mut self)
Drain pending CDP events into local buffers (non-blocking).
Sourcepub async fn pump_events(&mut self)
pub async fn pump_events(&mut self)
Drain events and ack screencast frames (required or Chrome stops sending).
Sourcepub async fn goto(
&mut self,
url: &str,
robots: RobotsPolicy,
) -> Result<Value, CliError>
pub async fn goto( &mut self, url: &str, robots: RobotsPolicy, ) -> Result<Value, CliError>
Navigate and wait for load (same process). Honors robots when policy is Honor.
Sourcepub async fn scrape(
&mut self,
url: &str,
robots: RobotsPolicy,
) -> Result<Value, CliError>
pub async fn scrape( &mut self, url: &str, robots: RobotsPolicy, ) -> Result<Value, CliError>
Minimal scrape: navigate, return source_url + body text + robots_policy.
Sourcepub async fn view(&mut self, verbose: bool) -> Result<Value, CliError>
pub async fn view(&mut self, verbose: bool) -> Result<Value, CliError>
Accessibility tree with agent-facing @eN refs.
pub async fn press( &mut self, target: &str, dblclick: bool, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn write( &mut self, target: &str, value: &str, include_snapshot: bool, ) -> Result<Value, CliError>
Sourcepub async fn click_at(
&mut self,
x: f64,
y: f64,
dblclick: bool,
include_snapshot: bool,
) -> Result<Value, CliError>
pub async fn click_at( &mut self, x: f64, y: f64, dblclick: bool, include_snapshot: bool, ) -> Result<Value, CliError>
Click at absolute page coordinates (requires experimental vision flag at CLI).
pub async fn keys( &mut self, key: &str, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn type_text( &mut self, target: Option<&str>, text: &str, clear: bool, submit: Option<&str>, focus_only: bool, ) -> Result<Value, CliError>
pub async fn eval( &mut self, expression: &str, args_json: Option<&str>, dialog_action: Option<&str>, file_path: Option<&Path>, ) -> Result<Value, CliError>
pub async fn wait_ms(&mut self, ms: u64) -> Result<Value, CliError>
pub async fn grab( &mut self, path: Option<&Path>, format: &str, full_page: bool, quality: Option<i32>, element: Option<&str>, ) -> Result<Value, CliError>
pub async fn extract( &mut self, target: &str, attr: Option<&str>, ) -> Result<Value, CliError>
pub async fn attr( &mut self, target: &str, name: &str, ) -> Result<Value, CliError>
Sourcepub async fn text(&mut self, target: &str) -> Result<Value, CliError>
pub async fn text(&mut self, target: &str) -> Result<Value, CliError>
PRD §7 text: extract visible text from a target.
Sourcepub async fn scroll(
&mut self,
target: Option<&str>,
delta_x: f64,
delta_y: f64,
) -> Result<Value, CliError>
pub async fn scroll( &mut self, target: Option<&str>, delta_x: f64, delta_y: f64, ) -> Result<Value, CliError>
PRD §7 scroll: scroll window or element by delta pixels.
pub async fn page_info(&mut self) -> Result<Value, CliError>
pub async fn assert_url( &mut self, value: &str, contains: bool, ) -> Result<Value, CliError>
pub async fn assert_text( &mut self, value: &str, target: Option<&str>, ) -> Result<Value, CliError>
pub async fn assert_console( &mut self, level: &str, max: u64, ) -> Result<Value, CliError>
pub fn console_list( &mut self, page_idx: Option<usize>, page_size: Option<usize>, types: Option<&str>, include_preserved: bool, service_worker_id: Option<&str>, ) -> Result<Value, CliError>
pub fn console_get(&mut self, id: usize) -> Result<Value, CliError>
pub fn console_clear(&mut self) -> Result<Value, CliError>
pub fn console_dump(&mut self, path: &Path) -> Result<Value, CliError>
pub fn net_list( &mut self, page_idx: Option<usize>, page_size: Option<usize>, resource_types: Option<&str>, include_preserved: bool, ) -> Result<Value, CliError>
Sourcepub fn net_get(
&mut self,
id: &str,
request_path: Option<&Path>,
response_path: Option<&Path>,
) -> Result<Value, CliError>
pub fn net_get( &mut self, id: &str, request_path: Option<&Path>, response_path: Option<&Path>, ) -> Result<Value, CliError>
Resolve a network entry by 0-based index or CDP requestId string.
pub async fn dialog( &mut self, accept: bool, prompt_text: Option<&str>, ) -> Result<Value, CliError>
pub async fn hover( &mut self, target: &str, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn drag( &mut self, from: &str, to: &str, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn fill_form( &mut self, fields: &[(String, String)], include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn upload( &mut self, target: &str, path: &Path, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn back(&mut self) -> Result<Value, CliError>
pub async fn forward(&mut self) -> Result<Value, CliError>
pub async fn reload(&mut self, ignore_cache: bool) -> Result<Value, CliError>
pub async fn page_list(&mut self) -> Result<Value, CliError>
pub async fn page_new( &mut self, url: Option<&str>, background: bool, isolated_context: bool, ) -> Result<Value, CliError>
pub async fn page_select( &mut self, index: usize, bring_to_front: bool, ) -> Result<Value, CliError>
pub async fn page_close( &mut self, index: Option<usize>, ) -> Result<Value, CliError>
pub async fn wait_for( &mut self, ms: Option<u64>, text: Option<&str>, selector: Option<&str>, state: Option<&str>, include_snapshot: bool, ) -> Result<Value, CliError>
pub async fn emulate( &mut self, user_agent: Option<&str>, locale: Option<&str>, timezone: Option<&str>, offline: bool, latitude: Option<f64>, longitude: Option<f64>, media: Option<&str>, network_conditions: Option<&str>, cpu_throttling_rate: Option<f64>, color_scheme: Option<&str>, extra_headers_json: Option<&str>, viewport: Option<&str>, ) -> Result<Value, CliError>
pub async fn resize( &mut self, width: i32, height: i32, scale: f64, mobile: bool, ) -> Result<Value, CliError>
pub async fn perf_start( &mut self, path: Option<&Path>, reload: bool, auto_stop: bool, ) -> Result<Value, CliError>
pub async fn perf_stop( &mut self, path: Option<&Path>, ) -> Result<Value, CliError>
pub async fn perf_insight( &mut self, name: Option<&str>, insight_set_id: Option<&str>, ) -> Result<Value, CliError>
Sourcepub fn perf_insight_file(
path: &Path,
name: Option<&str>,
) -> Result<Value, CliError>
pub fn perf_insight_file( path: &Path, name: Option<&str>, ) -> Result<Value, CliError>
Offline insight from a previously written trace path (no browser required).
pub async fn screencast_start( &mut self, path: Option<&Path>, ) -> Result<Value, CliError>
pub async fn screencast_stop( &mut self, path: Option<&Path>, ) -> Result<Value, CliError>
pub async fn heap_take(&mut self, path: &Path) -> Result<Value, CliError>
pub fn heap_file_summary(path: &Path) -> Result<Value, CliError>
pub fn heap_close(path: &Path) -> Result<Value, CliError>
pub fn heap_compare(base: &Path, current: &Path) -> Result<Value, CliError>
pub fn heap_details(path: &Path) -> Result<Value, CliError>
pub fn heap_dup_strings(path: &Path) -> Result<Value, CliError>
pub fn heap_class_nodes(path: &Path, id: u64) -> Result<Value, CliError>
pub fn heap_node_op(path: &Path, node: u64, op: &str) -> Result<Value, CliError>
Sourcepub fn heap_object_details(path: &Path, node: u64) -> Result<Value, CliError>
pub fn heap_object_details(path: &Path, node: u64) -> Result<Value, CliError>
Offline object details for one node id (distance, retained size, detachedness).
pub async fn extension_list(&mut self) -> Result<Value, CliError>
Sourcepub async fn extension_reload(&mut self, id: &str) -> Result<Value, CliError>
pub async fn extension_reload(&mut self, id: &str) -> Result<Value, CliError>
Reload extension service worker target by id prefix (one-shot CDP).
pub async fn extension_trigger(&mut self, id: &str) -> Result<Value, CliError>
Sourcepub async fn devtools3p_list(&mut self) -> Result<Value, CliError>
pub async fn devtools3p_list(&mut self) -> Result<Value, CliError>
Discover third-party developer tools via devtoolstooldiscovery CustomEvent.
pub async fn devtools3p_exec( &mut self, name: &str, params_json: Option<&str>, ) -> Result<Value, CliError>
Sourcepub async fn webmcp_list(&mut self) -> Result<Value, CliError>
pub async fn webmcp_list(&mut self) -> Result<Value, CliError>
List WebMCP / declarative tool forms on the page (Chrome 149+ features).