Page

Struct Page 

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

A browser page (tab).

Implementations§

Source§

impl Page

Source

pub fn goto(&self, url: impl Into<String>) -> GotoBuilder<'_>

Navigate to a URL.

Returns a builder for configuring navigation options.

§Example
use viewpoint_core::Page;
use viewpoint_core::DocumentLoadState;
use std::time::Duration;

// Simple navigation
page.goto("https://example.com").goto().await?;

// Navigation with options
page.goto("https://example.com")
    .wait_until(DocumentLoadState::DomContentLoaded)
    .timeout(Duration::from_secs(10))
    .goto()
    .await?;
Source

pub async fn goto_url( &self, url: &str, ) -> Result<NavigationResponse, NavigationError>

Navigate to a URL and wait for the specified load state.

This is a convenience method that calls goto(url).goto().await.

§Errors

Returns an error if:

  • The page is closed
  • Navigation fails
  • The wait times out
Source

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

Close this page.

§Errors

Returns an error if closing fails.

Source

pub fn target_id(&self) -> &str

Get the target ID.

Source

pub fn session_id(&self) -> &str

Get the session ID.

Source

pub fn frame_id(&self) -> &str

Get the main frame ID.

Source

pub fn is_closed(&self) -> bool

Check if this page has been closed.

Source

pub fn connection(&self) -> &Arc<CdpConnection>

Get a reference to the CDP connection.

Source

pub async fn url(&self) -> Result<String, PageError>

Get the current page URL.

§Errors

Returns an error if the page is closed or the evaluation fails.

Source

pub async fn title(&self) -> Result<String, PageError>

Get the current page title.

§Errors

Returns an error if the page is closed or the evaluation fails.

Source

pub fn locator(&self, selector: impl Into<String>) -> Locator<'_>

Create a locator for elements matching a CSS selector.

§Example
let button = page.locator("button.submit");
let items = page.locator(".list > .item");
Source

pub fn get_by_text(&self, text: impl Into<String>) -> Locator<'_>

Create a locator for elements containing the specified text.

§Example
let heading = page.get_by_text("Welcome");
let exact = page.get_by_text_exact("Welcome to our site");
Source

pub fn get_by_text_exact(&self, text: impl Into<String>) -> Locator<'_>

Create a locator for elements with exact text content.

Source

pub fn get_by_role(&self, role: AriaRole) -> RoleLocatorBuilder<'_>

Create a locator for elements with the specified ARIA role.

§Example
let buttons = page.get_by_role(AriaRole::Button);
let submit = page.get_by_role(AriaRole::Button).with_name("Submit");
Source

pub fn get_by_test_id(&self, test_id: impl Into<String>) -> Locator<'_>

Create a locator for elements with the specified test ID.

By default, looks for data-testid attribute.

§Example
let button = page.get_by_test_id("submit-button");
Source

pub fn get_by_label(&self, label: impl Into<String>) -> Locator<'_>

Create a locator for form controls by their associated label text.

§Example
let email = page.get_by_label("Email address");
Source

pub fn get_by_placeholder(&self, placeholder: impl Into<String>) -> Locator<'_>

Create a locator for inputs by their placeholder text.

§Example
let search = page.get_by_placeholder("Search...");

Trait Implementations§

Source§

impl Debug for Page

Source§

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

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

impl<'a> Expectable<'a> for Page

Source§

type Assertions = PageAssertions<'a>

The assertion builder type for this value.
Source§

fn assertions(&'a self) -> Self::Assertions

Create an assertion builder for this value.

Auto Trait Implementations§

§

impl Freeze for Page

§

impl !RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl !UnwindSafe for Page

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