pub struct Tab {
pub session_id: String,
pub target_id: String,
}Expand description
A CDP tab session, representing one browser tab.
Fields§
§session_id: StringThe CDP session ID for this tab’s target
target_id: StringThe target ID
Implementations§
Source§impl Tab
impl Tab
Sourcepub async fn create(
conn: &mut Connection,
ws_url: &str,
url: &str,
) -> Result<Self>
pub async fn create( conn: &mut Connection, ws_url: &str, url: &str, ) -> Result<Self>
Create a new tab. Uses Target.createTarget; falls back to HTTP /json/new for Dia.
Navigate the tab to a URL. Waits for the page to reach a stable state.
Sourcepub async fn evaluate(&self, conn: &mut Connection, js: &str) -> Result<Value>
pub async fn evaluate(&self, conn: &mut Connection, js: &str) -> Result<Value>
Evaluate JavaScript in the tab context and return the result.
Sourcepub async fn extract_text(&self, conn: &mut Connection) -> Result<String>
pub async fn extract_text(&self, conn: &mut Connection) -> Result<String>
Extract the page content. Returns innerText of body.
Sourcepub async fn extract_title(&self, conn: &mut Connection) -> Result<String>
pub async fn extract_title(&self, conn: &mut Connection) -> Result<String>
Extract the page title.
Sourcepub async fn extract_html(&self, conn: &mut Connection) -> Result<String>
pub async fn extract_html(&self, conn: &mut Connection) -> Result<String>
Extract HTML content.
Sourcepub async fn evaluate_all(
&self,
conn: &mut Connection,
scripts: &[&str],
) -> Result<Vec<Value>>
pub async fn evaluate_all( &self, conn: &mut Connection, scripts: &[&str], ) -> Result<Vec<Value>>
Execute multiple JS snippets in sequence.
Sourcepub async fn close(self, conn: &mut Connection)
pub async fn close(self, conn: &mut Connection)
Close this tab. Uses window.close() first, then Target.closeTarget as fallback.
Errors are logged but not propagated.
Auto Trait Implementations§
impl Freeze for Tab
impl RefUnwindSafe for Tab
impl Send for Tab
impl Sync for Tab
impl Unpin for Tab
impl UnsafeUnpin for Tab
impl UnwindSafe for Tab
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more