[][src]Trait thirtyfour::WebDriverCommands

pub trait WebDriverCommands {
#[must_use]    fn cmd<'life0, 'life1, 'async_trait>(
        &'life0 self,
        command: Command<'life1>
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Value>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn session(&self) -> WebDriverSession; #[must_use] fn close<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn get<'life0, 'async_trait, S: Into<String> + Send>(
        &'life0 self,
        url: S
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        S: 'async_trait,
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn current_url<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn page_source<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn title<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn find_element<'b, 'async_trait>(
        &'b self,
        by: By<'b>
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<WebElement<'b>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn find_elements<'b, 'async_trait>(
        &'b self,
        by: By<'b>
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<WebElement<'b>>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn execute_script<'b, 'async_trait>(
        &'b self,
        script: &'b str
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn execute_script_with_args<'b, 'async_trait>(
        &'b self,
        script: &'b str,
        args: &'b ScriptArgs
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn execute_async_script<'b, 'async_trait>(
        &'b self,
        script: &'b str
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn execute_async_script_with_args<'b, 'async_trait>(
        &'b self,
        script: &'b str,
        args: &'b ScriptArgs
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>>
    where
        'b: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn current_window_handle<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<WindowHandle>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn window_handles<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<WindowHandle>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn maximize_window<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn minimize_window<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn fullscreen_window<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn get_window_rect<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Rect>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn set_window_rect<'life0, 'async_trait>(
        &'life0 self,
        rect: OptionRect
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn back<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn forward<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn refresh<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn get_timeouts<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<TimeoutConfiguration>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn set_timeouts<'life0, 'async_trait>(
        &'life0 self,
        timeouts: TimeoutConfiguration
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn implicitly_wait<'life0, 'async_trait>(
        &'life0 self,
        time_to_wait: Duration
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn set_script_timeout<'life0, 'async_trait>(
        &'life0 self,
        time_to_wait: Duration
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn set_page_load_timeout<'life0, 'async_trait>(
        &'life0 self,
        time_to_wait: Duration
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
fn action_chain(&self) -> ActionChain { ... }
#[must_use] fn get_cookies<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<Cookie>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn get_cookie<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Cookie>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn delete_cookie<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn delete_all_cookies<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn add_cookie<'life0, 'async_trait>(
        &'life0 self,
        cookie: Cookie
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn screenshot_as_base64<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn screenshot_as_png<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<u8>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn screenshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
fn switch_to(&self) -> SwitchTo { ... }
#[must_use] fn set_window_name<'life0, 'life1, 'async_trait>(
        &'life0 self,
        window_name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }

All browser-level W3C WebDriver commands are implemented under this trait.


NOTE: Due to the use of async_trait, the documentation for this trait can be difficult to read. If you are finding it difficult to parse all the lifetime annotations etc you may find it easier to follow the sync documentation instead. Just remember to add .await after each method call.


Thirtyfour is structured as follows:

  • The WebDriverCommands trait contains all of the methods you would typically call in order to interact with the browser.
  • The GenericWebDriver struct implements the WebDriverCommands trait for a generic HTTP client.
  • The WebDriver struct is the GenericWebDriver implemented for a specific HTTP client.

You only need to use WebDriver in your code. Just create an instance of the WebDriver struct and it will have access to all of the methods from the WebDriverCommands trait.

For example:

let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;
driver.get("http://webappdemo").await?;
assert_eq!(driver.current_url().await?, "http://webappdemo/");

Required methods

#[must_use]fn cmd<'life0, 'life1, 'async_trait>(
    &'life0 self,
    command: Command<'life1>
) -> Pin<Box<dyn Future<Output = WebDriverResult<Value>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Convenience wrapper for running WebDriver commands.

For thirtyfour internal use only.

fn session(&self) -> WebDriverSession

Get the current session and http client.

For thirtyfour internal use only.

Loading content...

Provided methods

#[must_use]fn close<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Close the current window or tab.

Example:

// Open a new tab.
driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
// Get window handles and switch to the new tab.
let handles = driver.window_handles().await?;
driver.switch_to().window(&handles[1]).await?;
// We are now controlling the new tab.
driver.get("http://webappdemo").await?;
// Close the tab. This will return to the original tab.
driver.close().await?;

#[must_use]fn get<'life0, 'async_trait, S: Into<String> + Send>(
    &'life0 self,
    url: S
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    S: 'async_trait,
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Navigate to the specified URL.

Example:

driver.get("http://webappdemo").await?;

#[must_use]fn current_url<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get the current URL as a String.

Example:

driver.get("http://webappdemo").await?;
let url = driver.current_url().await?;

#[must_use]fn page_source<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get the page source as a String.

Example:

driver.get("http://webappdemo").await?;
let source = driver.page_source().await?;

#[must_use]fn title<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get the page title as a String.

Example:

driver.get("http://webappdemo").await?;
let title = driver.title().await?;

#[must_use]fn find_element<'b, 'async_trait>(
    &'b self,
    by: By<'b>
) -> Pin<Box<dyn Future<Output = WebDriverResult<WebElement<'b>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Search for an element on the current page using the specified selector.

Example:

let elem_text = driver.find_element(By::Name("input1")).await?;
let elem_button = driver.find_element(By::Id("button-set")).await?;
let elem_result = driver.find_element(By::Id("input-result")).await?;

#[must_use]fn find_elements<'b, 'async_trait>(
    &'b self,
    by: By<'b>
) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<WebElement<'b>>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Search for all elements on the current page that match the specified selector.

Example:

let elems = driver.find_elements(By::ClassName("section")).await?;
for elem in elems {
    assert!(elem.get_attribute("class").await?.contains("section"));
}

#[must_use]fn execute_script<'b, 'async_trait>(
    &'b self,
    script: &'b str
) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Execute the specified Javascript synchronously and return the result.

Example:

let ret = driver.execute_script(r#"
    let elem = document.getElementById("button1");
    elem.click();
    return elem;
    "#
).await?;
let elem_out = ret.get_element()?;
assert_eq!(elem_out.text().await?, "BUTTON 1");
let elem = driver.find_element(By::Id("button-result")).await?;
assert_eq!(elem.text().await?, "Button 1 clicked");

#[must_use]fn execute_script_with_args<'b, 'async_trait>(
    &'b self,
    script: &'b str,
    args: &'b ScriptArgs
) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Execute the specified Javascript synchronously and return the result.

Example:

use thirtyfour::ScriptArgs;
let elem = driver.find_element(By::Id("button1")).await?;
let mut args = ScriptArgs::new();
args.push(elem.clone())?;
args.push("TESTING")?;
let ret = driver.execute_script_with_args(r#"
    arguments[0].innerHTML = arguments[1];
    return arguments[0];
    "#, &args
).await?;
let elem_out = ret.get_element()?;
assert_eq!(elem_out.element_id, elem.element_id);
assert_eq!(elem_out.text().await?, "TESTING");

#[must_use]fn execute_async_script<'b, 'async_trait>(
    &'b self,
    script: &'b str
) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Execute the specified Javascrypt asynchronously and return the result.

Example:

let ret = driver.execute_async_script(r#"
    // Selenium automatically provides an extra argument which is a
    // function that receives the return value(s).
    let done = arguments[0];
    window.setTimeout(() => {
        let elem = document.getElementById("button1");
        elem.click();
        done(elem);
    }, 1000);
    "#
).await?;
let elem_out = ret.get_element()?;
assert_eq!(elem_out.text().await?, "BUTTON 1");
let elem = driver.find_element(By::Id("button-result")).await?;
assert_eq!(elem.text().await?, "Button 1 clicked");

#[must_use]fn execute_async_script_with_args<'b, 'async_trait>(
    &'b self,
    script: &'b str,
    args: &'b ScriptArgs
) -> Pin<Box<dyn Future<Output = WebDriverResult<ScriptRet<'b>>> + Send + 'async_trait>> where
    'b: 'async_trait,
    Self: Sync + 'async_trait, 

Execute the specified Javascrypt asynchronously and return the result.

Example:

use thirtyfour::ScriptArgs;
let elem = driver.find_element(By::Id("button1")).await?;
let mut args = ScriptArgs::new();
args.push(elem.clone())?;
args.push("TESTING")?;
let ret = driver.execute_async_script_with_args(r#"
    // Selenium automatically provides an extra argument which is a
    // function that receives the return value(s).
    let done = arguments[2];
    window.setTimeout(() => {
        arguments[0].innerHTML = arguments[1];
        done(arguments[0]);
    }, 1000);
    "#, &args
).await?;
let elem_out = ret.get_element()?;
assert_eq!(elem_out.element_id, elem.element_id);
assert_eq!(elem_out.text().await?, "TESTING");

#[must_use]fn current_window_handle<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<WindowHandle>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get the current window handle.

Example:

// Get the current window handle.
let handle = driver.current_window_handle().await?;
// Open a new tab.
driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
// Get window handles and switch to the new tab.
let handles = driver.window_handles().await?;
driver.switch_to().window(&handles[1]).await?;
// We are now controlling the new tab.
driver.get("http://webappdemo").await?;
assert_ne!(driver.current_window_handle().await?, handle);
// Switch back to original tab.
driver.switch_to().window(&handle).await?;
assert_eq!(driver.current_window_handle().await?, handle);

#[must_use]fn window_handles<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<WindowHandle>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get all window handles for the current session.

Example:

assert_eq!(driver.window_handles().await?.len(), 1);
// Open a new tab.
driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
// Get window handles and switch to the new tab.
let handles = driver.window_handles().await?;
assert_eq!(handles.len(), 2);
driver.switch_to().window(&handles[1]).await?;

#[must_use]fn maximize_window<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Maximize the current window.

Example:

driver.maximize_window().await?;

#[must_use]fn minimize_window<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Minimize the current window.

Example:

This example is not tested
driver.minimize_window().await?;

#[must_use]fn fullscreen_window<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Make the current window fullscreen.

Example:

driver.fullscreen_window().await?;

#[must_use]fn get_window_rect<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<Rect>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get the current window rectangle, in pixels.

The returned Rect struct has members x, y, width, height, all i32.

Example:

use thirtyfour::OptionRect;
let option_rect = OptionRect::new().with_pos(1, 1).with_size(800, 600);
driver.set_window_rect(option_rect.clone()).await?;
let rect = driver.get_window_rect().await?;
assert_eq!(OptionRect::from(rect), option_rect);

#[must_use]fn set_window_rect<'life0, 'async_trait>(
    &'life0 self,
    rect: OptionRect
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Set the current window rectangle, in pixels.

This requires an OptionRect, which is similar to Rect except all members are wrapped in Option.

Example:

use thirtyfour::OptionRect;
let r = OptionRect::new().with_size(1280, 720);
driver.set_window_rect(r).await?;

You can also convert from a Rect if you want to get the window size and modify it before setting it again.

use thirtyfour::OptionRect;
let rect = driver.get_window_rect().await?;
let option_rect = OptionRect::from(rect);
driver.set_window_rect(option_rect.with_width(1024)).await?;

#[must_use]fn back<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Go back. This is equivalent to clicking the browser's back button.

Example:

driver.back().await?;

#[must_use]fn forward<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Go forward. This is equivalent to clicking the browser's forward button.

Example:

let caps = DesiredCapabilities::chrome();
driver.forward().await?;

#[must_use]fn refresh<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Refresh the current page.

Example:

driver.refresh().await?;

#[must_use]fn get_timeouts<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<TimeoutConfiguration>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get all timeouts for the current session.

Example:

use thirtyfour::TimeoutConfiguration;
use std::time::Duration;
let timeouts = driver.get_timeouts().await?;
println!("Page load timeout = {:?}", timeouts.page_load());

#[must_use]fn set_timeouts<'life0, 'async_trait>(
    &'life0 self,
    timeouts: TimeoutConfiguration
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Set all timeouts for the current session.

Example:

use thirtyfour::TimeoutConfiguration;
use std::time::Duration;
// Setting timeouts to None means those timeout values will not be updated.
let timeouts = TimeoutConfiguration::new(None, Some(Duration::new(11, 0)), None);
driver.set_timeouts(timeouts.clone()).await?;

#[must_use]fn implicitly_wait<'life0, 'async_trait>(
    &'life0 self,
    time_to_wait: Duration
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Set the implicit wait timeout. This is how long the WebDriver will wait when querying elements.

By default this is set to 30 seconds.

NOTE: Depending on the kind of testing you want to do, you may find it more reliable to set the implicit wait time to 0 (no wait) and implement your own polling loop outside of thirtyfour.

Example:

use thirtyfour::TimeoutConfiguration;
use std::time::Duration;
let delay = Duration::new(11, 0);
driver.implicitly_wait(delay).await?;

#[must_use]fn set_script_timeout<'life0, 'async_trait>(
    &'life0 self,
    time_to_wait: Duration
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Set the script timeout. This is how long the WebDriver will wait for a Javascript script to execute.

By default this is set to 60 seconds.

Example:

use thirtyfour::TimeoutConfiguration;
use std::time::Duration;
let delay = Duration::new(11, 0);
driver.set_script_timeout(delay).await?;

#[must_use]fn set_page_load_timeout<'life0, 'async_trait>(
    &'life0 self,
    time_to_wait: Duration
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Set the page load timeout. This is how long the WebDriver will wait for the page to finish loading.

By default this is set to 60 seconds.

Example:

use thirtyfour::TimeoutConfiguration;
use std::time::Duration;
let delay = Duration::new(11, 0);
driver.set_page_load_timeout(delay).await?;

fn action_chain(&self) -> ActionChain

Create a new action chain for this session. Action chains can be used to simulate more complex user input actions involving key combinations, mouse movements, mouse click, right-click, and more.

Example:

let elem_text = driver.find_element(By::Name("input1")).await?;
let elem_button = driver.find_element(By::Id("button-set")).await?;

driver.action_chain()
    .send_keys_to_element(&elem_text, "thirtyfour")
    .move_to_element_center(&elem_button)
    .click()
    .perform().await?;

#[must_use]fn get_cookies<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<Cookie>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Get all cookies.

Example:

let cookies = driver.get_cookies().await?;
for cookie in &cookies {
    println!("Got cookie: {}", cookie.value());
}

Get the specified cookie.

Example:

let cookie = driver.get_cookie("key").await?;
println!("Got cookie: {}", cookie.value());

Delete the specified cookie.

Example:

driver.delete_cookie("key").await?;

#[must_use]fn delete_all_cookies<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Delete all cookies.

Example:

driver.delete_all_cookies().await?;

Add the specified cookie.

Example:

let cookie = Cookie::new("key", serde_json::json!("value"));
driver.add_cookie(cookie).await?;

#[must_use]fn screenshot_as_base64<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<String>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Take a screenshot of the current window and return it as a base64-encoded String.

#[must_use]fn screenshot_as_png<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = WebDriverResult<Vec<u8>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 

Take a screenshot of the current window and return it as PNG bytes.

#[must_use]fn screenshot<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 Path
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: Sync + 'async_trait, 

Take a screenshot of the current window and write it to the specified filename.

fn switch_to(&self) -> SwitchTo

Return a SwitchTo struct for switching to another window or frame.

#[must_use]fn set_window_name<'life0, 'life1, 'async_trait>(
    &'life0 self,
    window_name: &'life1 str
) -> Pin<Box<dyn Future<Output = WebDriverResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: Sync + 'async_trait, 

Set the current window name. Useful for switching between windows/tabs using driver.switch_to().window_name(name).

Example:

// Get the current window handle.
let handle = driver.current_window_handle().await?;
driver.set_window_name("main").await?;
// Open a new tab.
driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
// Get window handles and switch to the new tab.
let handles = driver.window_handles().await?;
driver.switch_to().window(&handles[1]).await?;
// We are now controlling the new tab.
driver.get("http://webappdemo").await?;
assert_ne!(driver.current_window_handle().await?, handle);
// Switch back to original tab using window name.
driver.switch_to().window_name("main").await?;
assert_eq!(driver.current_window_handle().await?, handle);
Loading content...

Implementors

impl<'a, '_> WebDriverCommands for WebDriverSession<'_>[src]

impl<T> WebDriverCommands for GenericWebDriver<T> where
    T: WebDriverHttpClientAsync
[src]

Loading content...