Window

Struct Window 

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

A handle to a Firefox browser window.

The window owns a Firefox process and profile, and holds a reference to the shared ConnectionPool for WebSocket communication. When dropped, the process is automatically killed.

§Example

let window = driver.window().headless().spawn().await?;

// Get the initial tab
let tab = window.tab();

// Create a new tab
let new_tab = window.new_tab().await?;

// Close the window
window.close().await?;

Implementations§

Source§

impl Window

Source

pub fn session_id(&self) -> SessionId

Returns the session ID.

Source

pub fn uuid(&self) -> &Uuid

Returns the Rust-side unique UUID.

Source

pub fn port(&self) -> u16

Returns the WebSocket port (shared across all windows).

Source

pub fn pid(&self) -> u32

Returns the Firefox process ID.

Source§

impl Window

Source

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

Closes the window and kills the Firefox process.

§Errors

Returns an error if the process cannot be killed.

Source§

impl Window

Source

pub fn tab(&self) -> Tab

Returns the initial tab for this window.

Source

pub async fn new_tab(&self) -> Result<Tab>

Creates a new tab in this window.

§Errors

Returns an error if tab creation fails.

Source

pub fn tab_count(&self) -> usize

Returns the number of tabs in this window.

Source

pub async fn steal_logs(&self) -> Result<Vec<Value>>

Steals logs from extension (returns and clears).

Useful for debugging extension issues.

Source§

impl Window

Source

pub async fn set_proxy(&self, config: ProxyConfig) -> Result<()>

Sets a proxy for all tabs in this window.

Window-level proxy applies to all tabs unless overridden by tab-level proxy.

§Example
use firefox_webdriver::ProxyConfig;

// HTTP proxy for all tabs
window.set_proxy(ProxyConfig::http("proxy.example.com", 8080)).await?;

// SOCKS5 proxy with auth
window.set_proxy(
    ProxyConfig::socks5("proxy.example.com", 1080)
        .with_credentials("user", "pass")
        .with_proxy_dns(true)
).await?;
Source

pub async fn clear_proxy(&self) -> Result<()>

Clears the proxy for this window.

After clearing, all tabs use direct connection (unless they have tab-level proxy).

Trait Implementations§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Window

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Window

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Window

§

impl !RefUnwindSafe for Window

§

impl Send for Window

§

impl Sync for Window

§

impl Unpin for Window

§

impl !UnwindSafe for Window

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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