Skip to main content

BrowserTestRunner

Struct BrowserTestRunner 

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

Runs crate::BrowserTest implementations through Chrome for Testing.

Implementations§

Source§

impl BrowserTestRunner

Source

pub fn new() -> Self

Create a runner using stable Chrome in headless mode.

Source

pub fn with_channel(self, channel: Channel) -> Self

Select the Chrome release channel.

Source

pub fn with_visibility( self, visibility: impl Into<BrowserTestVisibility>, ) -> Self

Configure Chrome visibility.

Source

pub fn with_pause(self, pause: impl Into<PauseConfig>) -> Self

Pause before starting webdriver when the config is enabled.

If the pause is aborted, Self::run returns successfully without starting webdriver or running any tests. If stdin reaches EOF while waiting for a pause response, Self::run returns an error instead.

Source

pub fn with_hint(self, hint: impl Display) -> Self

Set extra context shown when a manual pause prompt is enabled.

Source

pub fn with_chrome_capabilities( self, setup: impl Fn(&mut ChromeCapabilities) -> WebDriverResult<()> + Send + Sync + 'static, ) -> Self

Add custom Chrome capability setup applied to every WebDriver session.

The runner applies its own visible/headless configuration first, then applies custom setup functions in the order they were added. The setup function must be thread-safe because parallel browser tests can create multiple sessions at the same time.

Source

pub fn with_timeouts(self, timeouts: BrowserTimeouts) -> Self

Set timeouts applied to every session before running tests.

Individual crate::BrowserTest implementations can override this by returning Some from crate::BrowserTest::timeouts.

Source

pub fn with_webdriver_timeouts(self, timeouts: BrowserTimeouts) -> Self

👎Deprecated since 0.1.0:

use with_timeouts instead

Deprecated name for Self::with_timeouts.

Use Self::with_timeouts in new code.

Source

pub const fn with_element_query_wait(self, wait: ElementQueryWaitConfig) -> Self

Set the element query wait applied to every session before running tests.

Individual crate::BrowserTest implementations can override this by returning Some from crate::BrowserTest::element_query_wait.

Source

pub fn with_test_parallelism( self, parallelism: impl Into<BrowserTestParallelism>, ) -> Self

Configure how browser tests are scheduled.

Source

pub fn with_failure_policy( self, failure_policy: impl Into<BrowserTestFailurePolicy>, ) -> Self

Configure how browser test failures affect the rest of the run.

Source

pub fn with_driver_output(self, config: impl Into<DriverOutputConfig>) -> Self

Capture recent browser-driver output for failure diagnostics.

This stores capture configuration and creates a fresh capture buffer for each Self::run call.

Source

pub fn with_browser_driver_output( self, config: impl Into<DriverOutputConfig>, ) -> Self

👎Deprecated since 0.1.0:

use with_driver_output instead

Deprecated name for Self::with_driver_output.

Use Self::with_driver_output in new code.

Source

pub async fn run<Context, TestError>( &self, context: &Context, tests: BrowserTests<Context, TestError>, ) -> Result<(), Report<BrowserTestError>>
where Context: Sync + ?Sized, TestError: ?Sized + 'static,

Run every test with a fresh WebDriver session.

The shared chromedriver process is always terminated, even when a test returns an error or panics. Test panics are converted into BrowserTestError::Panic reports instead of being resumed.

Tests run sequentially and stop on the first failure by default. Use Self::with_test_parallelism to run multiple fresh WebDriver sessions at once. Use Self::with_failure_policy to execute every test and return all failures as child reports on one aggregate report.

Non-empty runs require a multithreaded Tokio runtime because Chromedriver::run requires one. Use #[tokio::test(flavor = "multi_thread")] for browser tests.

§Parameters

context: Given to each test.

§Errors

Returns an error if chromedriver cannot be started or terminated, if a session cannot be created, or if any test fails.

Trait Implementations§

Source§

impl Clone for BrowserTestRunner

Source§

fn clone(&self) -> BrowserTestRunner

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BrowserTestRunner

Source§

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

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

impl Default for BrowserTestRunner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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<O> ObjectMarkerFor<Local> for O
where O: 'static,

Source§

impl<O> ObjectMarkerFor<SendSync> for O
where O: 'static + Send + Sync,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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> Sink for T
where T: Send + 'static,