chrobot_extra/browser_utils
Utility functions for common browser automation tasks. Provides URL waiting and element visibility checking capabilities.
Values
pub fn await_visible(
page page: chrobot_extra.Page,
selector selector: String,
time_out timeout: Int,
) -> Result(Bool, chrome.RequestError)
Wait until an element matching the CSS selector becomes visible. The timeout is specified in milliseconds.
Example
await_visible(page, selector: "#my-element", time_out: 10_000)
pub fn get_url(
page: chrobot_extra.Page,
) -> Result(String, chrome.RequestError)
Get the current page URL.
pub fn is_visible(
page page: chrobot_extra.Page,
selector selector: String,
) -> Result(Bool, chrome.RequestError)
Check if an element matching the CSS selector is visible on the page. Returns True if the element exists in the DOM and is visually visible.
pub fn wait_for_url(
page page: chrobot_extra.Page,
matching predicate: fn(String) -> Bool,
time_out timeout: Int,
) -> Result(String, chrome.RequestError)
Wait until the page URL matches the given predicate. The timeout is specified in milliseconds.
Example
// Wait up to 5 minutes for URL to change away from login page
wait_for_url(page, matching: fn(url) { !string.contains(url, "login") }, time_out: 300_000)