pub struct Frame { /* private fields */ }Expand description
A frame within a page.
Frames are separate browsing contexts, typically created by <iframe> elements.
Each frame has its own DOM and JavaScript execution context.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn parent_id(&self) -> Option<&str>
pub fn parent_id(&self) -> Option<&str>
Get the parent frame ID.
Returns None for the main frame.
Sourcepub fn is_detached(&self) -> bool
pub fn is_detached(&self) -> bool
Check if the frame has been detached.
Sourcepub async fn content(&self) -> Result<String, PageError>
pub async fn content(&self) -> Result<String, PageError>
Get the frame’s HTML content.
§Errors
Returns an error if the frame is detached or the evaluation fails.
Sourcepub async fn title(&self) -> Result<String, PageError>
pub async fn title(&self) -> Result<String, PageError>
Get the frame’s document title.
§Errors
Returns an error if the frame is detached or the evaluation fails.
Sourcepub async fn goto_with_options(
&self,
url: &str,
wait_until: DocumentLoadState,
timeout: Duration,
) -> Result<(), NavigationError>
pub async fn goto_with_options( &self, url: &str, wait_until: DocumentLoadState, timeout: Duration, ) -> Result<(), NavigationError>
Navigate the frame to a URL with options.
§Errors
Returns an error if the frame is detached or navigation fails.
Sourcepub async fn set_content(&self, html: &str) -> Result<(), PageError>
pub async fn set_content(&self, html: &str) -> Result<(), PageError>
Set the frame’s HTML content.
§Errors
Returns an error if the frame is detached or setting content fails.
Sourcepub async fn wait_for_load_state(
&self,
state: DocumentLoadState,
) -> Result<(), NavigationError>
pub async fn wait_for_load_state( &self, state: DocumentLoadState, ) -> Result<(), NavigationError>
Wait for the frame to reach a specific load state.
§Errors
Returns an error if the wait times out or the frame is detached.
Sourcepub async fn wait_for_load_state_with_timeout(
&self,
state: DocumentLoadState,
timeout: Duration,
) -> Result<(), NavigationError>
pub async fn wait_for_load_state_with_timeout( &self, state: DocumentLoadState, timeout: Duration, ) -> Result<(), NavigationError>
Wait for the frame to reach a specific load state with timeout.
§Errors
Returns an error if the wait times out or the frame is detached.
Sourcepub async fn child_frames(&self) -> Result<Vec<Frame>, PageError>
pub async fn child_frames(&self) -> Result<Vec<Frame>, PageError>
Get child frames of this frame.
Returns a list of frames that are direct children of this frame.
§Errors
Returns an error if querying the frame tree fails.
Sourcepub async fn parent_frame(&self) -> Result<Option<Frame>, PageError>
pub async fn parent_frame(&self) -> Result<Option<Frame>, PageError>
Get the parent frame.
Returns None if this is the main frame.
§Errors
Returns an error if querying the frame tree fails.
Sourcepub async fn aria_snapshot(&self) -> Result<AriaSnapshot, PageError>
pub async fn aria_snapshot(&self) -> Result<AriaSnapshot, PageError>
Capture an ARIA accessibility snapshot of this frame’s document.
The snapshot represents the accessible structure of the frame’s content as it would be exposed to assistive technologies. This is useful for accessibility testing and MCP (Model Context Protocol) integrations.
§Frame Boundaries
Any iframes within this frame are marked as frame boundaries in the snapshot
with is_frame: true. Their content is NOT traversed (for security reasons).
To capture multi-frame accessibility trees, use Page::aria_snapshot_with_frames().
§Example
use viewpoint_core::Page;
// Get snapshot of main frame
let main_frame = page.main_frame().await?;
let snapshot = main_frame.aria_snapshot().await?;
println!("{}", snapshot);
// Get snapshot of a child iframe
for frame in page.frames().await? {
if !frame.is_main() {
let frame_snapshot = frame.aria_snapshot().await?;
println!("Frame {}: {}", frame.name(), frame_snapshot);
}
}§Errors
Returns an error if:
- The frame is detached
- JavaScript evaluation fails
- The snapshot cannot be parsed