Struct Driver

Source
pub struct Driver(/* private fields */);

Implementations§

Source§

impl Driver

Source

pub async fn new( webdriver_url: &str, user_agent: Option<String>, ) -> Result<Self>

Create a new webdriver session on the specified server

Source

pub async fn goto<'a>(&'a self, url: &'a str) -> Result<()>

Navigate directly to the given URL.

Source

pub async fn current_url(&self) -> Result<Url>

Retrieve the currently active URL for this session.

Source

pub async fn source(&self) -> Result<String>

Get the HTML source for the current page.

Source

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

Go back to the previous page.

Source

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

Refresh the current previous page.

Source

pub async fn switch_to_frame(&self, frame: WebElement) -> Result<()>

Switch the focus to the frame contained in Element

Source

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

Switch the focus to this frame’s parent frame

Source

pub async fn switch_to_window(&self, window: String) -> Result<()>

Switch the focus to the window identified by handle

Source

pub async fn execute(&self, script: String, args: Vec<Value>) -> Result<Value>

Execute the given JavaScript script in the current browser session.

args is available to the script inside the arguments array. Since Element implements ToJson, you can also provide serialized Elements as arguments, and they will correctly serialize to DOM elements on the other side.

Source

pub async fn wait_for_navigation(&self, current: Option<Url>) -> Result<()>

Wait for the page to navigate to a new URL before proceeding.

If the current URL is not provided, self.current_url() will be used. Note however that this introduces a race condition: the browser could finish navigating before we call current_url(), which would lead to an eternal wait.

Source

pub async fn find( &self, locator: Locator, root: Option<WebElement>, ) -> Result<WebElement>

Starting from the document root, find the first element on the page that matches the specified selector.

Source

pub async fn find_all( &self, locator: Locator, root: Option<WebElement>, ) -> Result<Vec<WebElement>>

Source

pub async fn wait_for_find( &self, search: Locator, root: Option<WebElement>, ) -> Result<WebElement>

Wait for the specified element(s) to appear on the page

Source

pub async fn wait_for_find_all( &self, search: Locator, root: Option<WebElement>, ) -> Result<Vec<WebElement>>

Wait for the specified element(s) to appear on the page

Source

pub async fn attr( &self, eid: WebElement, attribute: String, ) -> Result<Option<String>>

Look up an attribute value for this element by name.

Source

pub async fn prop( &self, eid: WebElement, prop: String, ) -> Result<Option<String>>

Look up a DOM property for this element by name.

Source

pub async fn text(&self, eid: WebElement) -> Result<String>

Retrieve the text contents of this elment.

Source

pub async fn html(&self, eid: WebElement, inner: bool) -> Result<String>

Retrieve the HTML contents of this element. if inner is true, also return the wrapping nodes html. Note: this is the same as calling prop("innerHTML") or prop("outerHTML").

Source

pub async fn click(&self, eid: WebElement) -> Result<()>

Click on this element

Source

pub async fn scroll_into_view(&self, eid: WebElement) -> Result<()>

Scroll this element into view

Source

pub async fn follow(&self, eid: WebElement) -> Result<()>

Follow the href target of the element matching the given CSS selector without causing a click interaction.

Source

pub async fn set_by_name( &self, eid: WebElement, name: String, value: String, ) -> Result<()>

Set the value of the input element named name which is a child of eid

Source

pub async fn submit(&self, eid: WebElement) -> Result<()>

Submit the form specified by eid with the first submit button

Source

pub async fn submit_with(&self, eid: WebElement, button: Locator) -> Result<()>

Submit the form eid using the button matched by the given selector.

Source

pub async fn submit_using( &self, eid: WebElement, button_label: String, ) -> Result<()>

Submit this form using the form submit button with the given label (case-insensitive).

Source

pub async fn submit_direct(&self, eid: WebElement) -> Result<()>

Submit this form directly, without clicking any buttons.

This can be useful to bypass forms that perform various magic when the submit button is clicked, or that hijack click events altogether.

Note that since no button is actually clicked, the name=value pair for the submit button will not be submitted. This can be circumvented by using submit_sneaky instead.

Source

pub async fn submit_sneaky( &self, eid: WebElement, field: String, value: String, ) -> Result<()>

Submit this form directly, without clicking any buttons, and with an extra field.

Like submit_direct, this method will submit this form without clicking a submit button. However, it will also inject a hidden input element on the page that carries the given field=value mapping. This allows you to emulate the form data as it would have been if the submit button was indeed clicked.

Auto Trait Implementations§

§

impl Freeze for Driver

§

impl !RefUnwindSafe for Driver

§

impl Send for Driver

§

impl Sync for Driver

§

impl Unpin for Driver

§

impl !UnwindSafe for Driver

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

impl<T> ErasedDestructor for T
where T: 'static,