Struct thirtyfour::WebDriver

source ·
pub struct WebDriver {
    pub handle: Arc<SessionHandle>,
}
Expand description

The WebDriver struct encapsulates an async Selenium WebDriver browser session.

§Example:

use thirtyfour::prelude::*;

let caps = DesiredCapabilities::firefox();
// NOTE: this assumes you have a WebDriver compatible server running
//       at http://localhost:4444
//       e.g. `geckodriver -p 4444`
// NOTE: If using selenium 3.x, use "http://localhost:4444/wd/hub/session" for the url.
let driver = WebDriver::new("http://localhost:4444", caps).await?;
driver.goto("https://www.rust-lang.org/").await?;
// Always remember to close the session.
driver.quit().await?;

Fields§

§handle: Arc<SessionHandle>

The underlying session handle.

Implementations§

source§

impl WebDriver

source

pub async fn new<S, C>(server_url: S, capabilities: C) -> WebDriverResult<Self>
where S: Into<String>, C: Into<Capabilities>,

Create a new WebDriver as follows:

§Example
let caps = DesiredCapabilities::firefox();
// NOTE: this assumes you have a WebDriver compatible server running
//       at http://localhost:4444
//       e.g. `geckodriver -p 4444`
// NOTE: If using selenium 3.x, use "http://localhost:4444/wd/hub/session" for the url.
let driver = WebDriver::new("http://localhost:4444", caps).await?;
§Using Selenium Server
  • For selenium 3.x, you need to also add “/wd/hub/session” to the end of the url (e.g. “http://localhost:4444/wd/hub/session”)
  • For selenium 4.x and later, no path should be needed on the url.
§Troubleshooting
  • If the webdriver appears to hang or give no response, please check that the capabilities object is of the correct type for that webdriver.
source

pub async fn new_with_config<S, C>( server_url: S, capabilities: C, config: WebDriverConfig ) -> WebDriverResult<Self>
where S: Into<String>, C: Into<Capabilities>,

Create a new WebDriver with the specified WebDriverConfig.

Use WebDriverConfig::builder().build() to construct the config.

source

pub fn clone_with_config(&self, config: WebDriverConfig) -> Self

Clone this WebDriver keeping the session handle, but supplying a new WebDriverConfig.

This still uses the same underlying client, and still controls the same browser session, but uses a different WebDriverConfig for this instance.

This is useful in cases where you want to specify a custom poller configuration (or some other configuration option) for only one instance of WebDriver.

source

pub async fn quit(self) -> WebDriverResult<()>

End the webdriver session and close the browser.

NOTE: The browser will not close automatically when WebDriver goes out of scope. Thus if you intend for the browser to close once you are done with it, then you must call this method at that point, and await it.

Trait Implementations§

source§

impl Clone for WebDriver

source§

fn clone(&self) -> WebDriver

Returns a copy 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 WebDriver

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for WebDriver

The Deref implementation allows the WebDriver to “fall back” to SessionHandle and exposes all of the methods there without requiring us to use an async_trait. See documentation at the top of this module for more details on the design.

§

type Target = Arc<SessionHandle>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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

§

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>,

§

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>,

§

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