[][src]Struct headless_chrome::browser::tab::Tab

pub struct Tab { /* fields omitted */ }

A handle to a single page. Exposes methods for simulating user actions (clicking, typing), and also for getting information about the DOM and other parts of the page.

Methods

impl<'a> Tab[src]

pub fn new(target_info: TargetInfo, transport: Arc<Transport>) -> Fallible<Self>[src]

pub fn update_target_info(&self, target_info: TargetInfo)[src]

pub fn get_target_id(&self) -> &TargetId[src]

pub fn get_target_info(&self) -> Fallible<TargetInfo>[src]

Fetches the most recent info about this target

pub fn get_browser_context_id(&self) -> Fallible<Option<String>>[src]

pub fn get_url(&self) -> String[src]

pub fn call_method<C>(&self, method: C) -> Fallible<C::ReturnObject> where
    C: Method + Serialize + Debug
[src]

pub fn wait_until_navigated(&self) -> Fallible<&Self>[src]

pub fn navigate_to(&self, url: &str) -> Fallible<&Self>[src]

pub fn wait_for_element(&self, selector: &str) -> Fallible<Element>[src]

pub fn wait_for_element_with_custom_timeout(
    &self,
    selector: &str,
    timeout: Duration
) -> Fallible<Element>
[src]

pub fn wait_for_elements(&self, selector: &str) -> Fallible<Vec<Element>>[src]

pub fn find_element(&self, selector: &str) -> Fallible<Element>[src]

pub fn get_document(&self) -> Fallible<Node>[src]

pub fn find_elements(&self, selector: &str) -> Fallible<Vec<Element>>[src]

pub fn describe_node(&self, node_id: NodeId) -> Fallible<Node>[src]

pub fn type_str(&self, string_to_type: &str) -> Fallible<&Self>[src]

pub fn press_key(&self, key: &str) -> Fallible<&Self>[src]

pub fn move_mouse_to_point(&self, point: Point) -> Fallible<&Self>[src]

Moves the mouse to this point (dispatches a mouseMoved event)

pub fn click_point(&self, point: Point) -> Fallible<&Self>[src]

pub fn capture_screenshot(
    &self,
    format: ScreenshotFormat,
    clip: Option<Viewport>,
    from_surface: bool
) -> Fallible<Vec<u8>>
[src]

Capture a screenshot of the current page.

If clip is given, the screenshot is taken of the specified region only. Element::get_box_model() can be used to get regions of certains elements on the page; there is also Element::capture_screenhot() as a shorthand.

If from_surface is true, the screenshot is taken from the surface rather than the view.

use headless_chrome::{protocol::page::ScreenshotFormat, Browser, LaunchOptionsBuilder};
let browser = Browser::new(LaunchOptionsBuilder::default().build().unwrap())?;
let tab = browser.wait_for_initial_tab()?;
let viewport = tab.navigate_to("https://en.wikipedia.org/wiki/WebKit")?
    .wait_for_element("#mw-content-text > div > table.infobox.vevent")?
    .get_box_model()?
    .margin_viewport();
 let png_data = tab.capture_screenshot(ScreenshotFormat::PNG, Some(viewport), true)?;

pub fn print_to_pdf(
    &self,
    options: Option<PrintToPdfOptions>
) -> Fallible<Vec<u8>>
[src]

pub fn reload(
    &self,
    ignore_cache: bool,
    script_to_evaluate: Option<&str>
) -> Fallible<&Self>
[src]

Reloads given page optionally ignoring the cache

If ignore_cache is true, the browser cache is ignored (as if the user pressed Shift+F5). If script_to_evaluate is given, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.

pub fn enable_profiler(&self) -> Fallible<&Self>[src]

Enables the profiler

pub fn disable_profiler(&self) -> Fallible<&Self>[src]

Disables the profiler

pub fn start_js_coverage(&self) -> Fallible<&Self>[src]

Starts tracking which lines of JS have been executed

Will return error unless enable_profiler has been called.

Equivalent to hitting the record button in the "coverage" tab in Chrome DevTools. See the file tests/coverage.rs for an example.

By default we enable the 'detailed' flag on StartPreciseCoverage, which enables block-level granularity, and also enable 'call_count' (which when disabled always sets count to 1 or 0).

pub fn stop_js_coverage(&self) -> Fallible<&Self>[src]

Stops tracking which lines of JS have been executed If you're finished with the profiler, don't forget to call disable_profiler.

pub fn take_precise_js_coverage(&self) -> Fallible<Vec<ScriptCoverage>>[src]

Collect coverage data for the current isolate, and resets execution counters.

Precise code coverage needs to have started (see start_js_coverage).

Will only send information about code that's been executed since this method was last called, or (if this is the first time) since calling start_js_coverage. Another way of thinking about it is: every time you call this, the call counts for FunctionRanges are reset after returning.

The format of the data is a little unintuitive, see here for details: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage

pub fn enable_request_interception(
    &self,
    patterns: &[RequestPattern],
    interceptor: RequestInterceptor
) -> Fallible<()>
[src]

Allows you to inspect outgoing network requests from the tab, and optionally return your own responses to them

The interceptor argument is a closure which takes this tab's Transport and its SessionID so that you can call methods from within the closure using transport.call_method_on_target.

The closure needs to return a variant of RequestInterceptionDecision (so, Continue or Response(String)).

pub fn continue_intercepted_request(
    &self,
    interception_id: &str,
    modified_response: Option<&str>
) -> Fallible<()>
[src]

Once you have an intercepted request, you can choose to let it continue by calling this.

If you specify a 'modified_response', that's what the requester in the page will receive instead of what they normally would've received.

pub fn enable_response_handling(&self, handler: ResponseHandler) -> Fallible<()>[src]

pub fn enable_debugger(&self) -> Fallible<()>[src]

Enables Debugger

pub fn disable_debugger(&self) -> Fallible<()>[src]

Disables Debugger

pub fn get_script_source(&self, script_id: &str) -> Fallible<String>[src]

Returns source for the script with given id.

Debugger must be enabled.

Trait Implementations

impl Drop for Tab[src]

Auto Trait Implementations

impl Send for Tab

impl Unpin for Tab

impl Sync for Tab

impl UnwindSafe for Tab

impl RefUnwindSafe for Tab

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.