Skip to main content

BrowserClient

Struct BrowserClient 

Source
pub struct BrowserClient { /* private fields */ }
Expand description

Browser client for high-level operations

Implementations§

Source§

impl BrowserClient

Source

pub fn new(executor: Arc<dyn BrowserExecutor>) -> Self

Create a new browser client with the given executor

Source

pub fn with_default_config() -> Self

Create a client with default configuration

Source

pub fn executor(&self) -> &Arc<dyn BrowserExecutor>

Get reference to executor (for extension traits)

Source

pub async fn open(&self, url: &str) -> Result<(), BrowserError>

Open a URL in the browser

Source

pub async fn close(&self) -> Result<(), BrowserError>

Close the browser

Source

pub fn is_daemon_running(&self) -> bool

Check if browser daemon is running

Trait Implementations§

Source§

impl InteractionExt for BrowserClient

Source§

async fn click(&self, selector: &str) -> Result<(), BrowserError>

Click an element by selector
Source§

async fn dblclick(&self, selector: &str) -> Result<(), BrowserError>

Double-click an element
Source§

async fn fill(&self, selector: &str, text: &str) -> Result<(), BrowserError>

Fill a form field with text
Source§

async fn type_text( &self, selector: &str, text: &str, ) -> Result<(), BrowserError>

Type text into an element (character by character)
Source§

async fn press(&self, key: &str) -> Result<(), BrowserError>

Press a keyboard key
Source§

async fn hover(&self, selector: &str) -> Result<(), BrowserError>

Hover over an element
Source§

async fn select_option( &self, selector: &str, value: &str, ) -> Result<(), BrowserError>

Select an option in a dropdown
Source§

async fn focus(&self, selector: &str) -> Result<(), BrowserError>

Focus an element
Source§

async fn check(&self, selector: &str) -> Result<(), BrowserError>

Check a checkbox
Source§

async fn uncheck(&self, selector: &str) -> Result<(), BrowserError>

Uncheck a checkbox
Source§

async fn scrollintoview(&self, selector: &str) -> Result<(), BrowserError>

Scroll an element into view
Source§

async fn drag(&self, source: &str, target: &str) -> Result<(), BrowserError>

Drag and drop from source to destination
Source§

async fn upload( &self, selector: &str, files: &[&str], ) -> Result<(), BrowserError>

Upload files to a file input
Source§

async fn scroll( &self, direction: &str, pixels: Option<u32>, ) -> Result<(), BrowserError>

Scroll the page
Source§

impl NavigationExt for BrowserClient

Source§

async fn back(&self) -> Result<(), BrowserError>

Navigate back in browser history
Source§

async fn forward(&self) -> Result<(), BrowserError>

Navigate forward in browser history
Source§

async fn reload(&self) -> Result<(), BrowserError>

Reload the current page
Source§

impl QueryExt for BrowserClient

Source§

async fn snapshot(&self) -> Result<SnapshotResult, BrowserError>

Take an accessibility snapshot of the current page
Source§

async fn screenshot(&self, path: &str) -> Result<(), BrowserError>

Take a screenshot and save to path
Source§

async fn pdf(&self, path: &str) -> Result<(), BrowserError>

Save page as PDF
Source§

async fn eval(&self, script: &str) -> Result<JsonValue, BrowserError>

Evaluate JavaScript in the browser
Source§

async fn get(&self, what: &str) -> Result<String, BrowserError>

Get page content (text, html, value, url, or title)
Source§

async fn get_attr( &self, selector: &str, attr: &str, ) -> Result<String, BrowserError>

Get element attribute value
Source§

async fn get_count(&self, selector: &str) -> Result<usize, BrowserError>

Get count of elements matching selector
Source§

async fn get_box(&self, selector: &str) -> Result<BoundingBox, BrowserError>

Get element bounding box
Source§

async fn get_styles( &self, selector: &str, ) -> Result<HashMap<String, String>, BrowserError>

Get element computed styles
Source§

async fn find( &self, locator_type: &str, value: &str, action: &str, action_value: Option<&str>, ) -> Result<String, BrowserError>

Find elements using various locator strategies
Source§

async fn is_(&self, what: &str, selector: &str) -> Result<bool, BrowserError>

Check element state (visible, hidden, enabled, disabled, editable)
Source§

async fn download( &self, selector: &str, path: &str, ) -> Result<String, BrowserError>

Download file from link/button to path
Source§

impl StorageExt for BrowserClient

Source§

async fn cookies(&self) -> Result<Vec<Cookie>, BrowserError>

Get all cookies
Source§

async fn cookies_set(&self, name: &str, value: &str) -> Result<(), BrowserError>

Set a cookie
Source§

async fn storage_get( &self, storage_type: &str, key: Option<&str>, ) -> Result<JsonValue, BrowserError>

Get storage value (local or session)
Source§

async fn storage_set( &self, storage_type: &str, key: &str, value: &str, ) -> Result<(), BrowserError>

Set storage value (local or session)
Source§

async fn network_requests( &self, filter: Option<&str>, ) -> Result<Vec<Request>, BrowserError>

Get network requests
Source§

async fn set_viewport( &self, width: u32, height: u32, scale: Option<f32>, ) -> Result<(), BrowserError>

Set viewport size
Source§

async fn set_device(&self, name: &str) -> Result<(), BrowserError>

Set device emulation
Source§

async fn set_geo( &self, latitude: f64, longitude: f64, ) -> Result<(), BrowserError>

Set geolocation
Source§

impl TabsExt for BrowserClient

Source§

async fn tab_list(&self) -> Result<Vec<TabInfo>, BrowserError>

List all browser tabs
Source§

async fn tab_new(&self, url: Option<&str>) -> Result<(), BrowserError>

Open a new tab, optionally with URL
Source§

async fn tab_close(&self, index: Option<usize>) -> Result<(), BrowserError>

Close a tab by index (or current if None)
Source§

async fn tab_select(&self, index: usize) -> Result<(), BrowserError>

Select/switch to a tab by index
Source§

async fn dialog_accept(&self, text: Option<&str>) -> Result<(), BrowserError>

Accept a dialog (alert, confirm, prompt) with optional text
Source§

async fn dialog_dismiss(&self) -> Result<(), BrowserError>

Dismiss a dialog (alert, confirm, prompt)
Source§

impl WaitingExt for BrowserClient

Source§

async fn wait_for(&self, condition: &str) -> Result<(), BrowserError>

Wait for a condition (text, element, or timeout)
Source§

async fn wait_for_text(&self, text: &str) -> Result<(), BrowserError>

Wait for text to appear on page
Source§

async fn wait_for_url(&self, pattern: &str) -> Result<(), BrowserError>

Wait for URL pattern match
Source§

async fn wait_for_load(&self, state: &str) -> Result<(), BrowserError>

Wait for page load state (networkidle, domcontentloaded, load)
Source§

async fn wait_for_download( &self, path: Option<&str>, ) -> Result<String, BrowserError>

Wait for download to complete, returns download path
Source§

async fn wait_for_fn(&self, js: &str) -> Result<(), BrowserError>

Wait for JavaScript function to return truthy value
Source§

async fn wait_for_state( &self, selector: &str, state: &str, ) -> Result<(), BrowserError>

Wait for element state (visible, hidden, attached, detached, enabled, disabled)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more