pub struct TabHandle {
pub tab_id: String,
pub parent_browser: String,
pub created: bool,
pub depth: usize,
}Expand description
State for a mounted Tab anchor.
Fields§
§tab_id: StringCDP target ID for this tab.
parent_browser: StringName of the parent Browser anchor.
created: boolTrue if this tab was opened by the workflow (closed on unmount). False if this tab was attached to an existing tab (left open on unmount).
depth: usizeSubflow depth when this tab was mounted (mirrors AnchorDef::mount_depth).
Implementations§
Source§impl TabHandle
impl TabHandle
Sourcepub fn mount(
def: &AnchorDef,
browser: &impl Browser,
) -> Result<Self, AutomataError>
pub fn mount( def: &AnchorDef, browser: &impl Browser, ) -> Result<Self, AutomataError>
Open or attach to a CDP tab as described by def.
- If
def.urlis set: opens a new tab, navigates to the URL, and waits fordocument.readyState === 'complete'(up to 30 s).created = true. - Otherwise: polls
browser.tabs()until one matchesdef.selector(up to 30 s).created = false— the tab is left open on unmount.
Sourcepub fn close_if_created(&self, browser: &impl Browser)
pub fn close_if_created(&self, browser: &impl Browser)
Close this tab via browser if the workflow created it; no-op if attached.
Sourcepub fn scoped_selector(
&self,
browser: &impl Browser,
selector: &SelectorPath,
) -> Result<(String, SelectorPath), AutomataError>
pub fn scoped_selector( &self, browser: &impl Browser, selector: &SelectorPath, ) -> Result<(String, SelectorPath), AutomataError>
Build a document-scoped selector for this tab, verifying it is focused first.
Checks document.hasFocus() via CDP and returns an error if the tab is not
the active foreground tab — prevents silently querying the wrong document.
Returns (parent_browser_name, scoped_selector) so the caller can
delegate find_descendant to the parent Browser anchor.