Skip to main content

PageObject

Trait PageObject 

Source
pub trait PageObject {
    // Required method
    fn url_pattern(&self) -> &str;

    // Provided methods
    fn is_loaded(&self) -> bool { ... }
    fn load_timeout_ms(&self) -> u64 { ... }
    fn page_name(&self) -> &str { ... }
}
Expand description

Trait for page objects representing a page or component in the UI.

Implement this trait to create reusable page objects that encapsulate the structure and behavior of UI pages.

§Example

struct LoginPage {
    username_input: Locator,
    password_input: Locator,
    submit_button: Locator,
}

impl PageObject for LoginPage {
    fn url_pattern(&self) -> &str {
        "/login"
    }

    fn is_loaded(&self) -> bool {
        // Check if page-specific elements are present
        true
    }
}

impl LoginPage {
    pub fn new() -> Self {
        Self {
            username_input: Locator::new(Selector::css("input[name='username']")),
            password_input: Locator::new(Selector::css("input[name='password']")),
            submit_button: Locator::new(Selector::css("button[type='submit']")),
        }
    }

    pub async fn login(&self, username: &str, password: &str) -> ProbarResult<()> {
        // Implementation
        Ok(())
    }
}

Required Methods§

Source

fn url_pattern(&self) -> &str

URL pattern that matches this page (e.g., “/login”, “/users/*”)

Provided Methods§

Source

fn is_loaded(&self) -> bool

Check if the page is fully loaded and ready for interaction

Source

fn load_timeout_ms(&self) -> u64

Optional wait time for page load (in milliseconds)

Source

fn page_name(&self) -> &str

Get the page name for logging/debugging

Implementors§