[][src]Struct headless_chrome::browser::tab::element::Element

pub struct Element<'a> {
    pub remote_object_id: String,
    pub backend_node_id: NodeId,
    pub parent: &'a Tab,

A handle to a DOM Element.

Typically you get access to these by passing Tab.wait_for_element a CSS selector. Once you have a handle to an element, you can click it, type into it, inspect its attributes, and more. You can even run a JavaScript function inside the tab which can reference the element via this.


remote_object_id: Stringbackend_node_id: NodeIdparent: &'a Tab


impl<'a> Element<'a>[src]

pub fn new(parent: &'a Tab, node_id: NodeId) -> Fallible<Self>[src]

Using a 'node_id', of the type returned by QuerySelector and QuerySelectorAll, this finds the 'backend_node_id' and 'remote_object_id' which are stable identifiers, unlike node_id. We use these two when making various calls to the API because of that.

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

Moves the mouse to the middle of this element

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

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

pub fn call_js_fn(
    function_declaration: &str,
    await_promise: bool
) -> Fallible<RemoteObject>

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

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

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

Capture a screenshot of this element.

The screenshot is taken from the surface using this element's content-box.

use headless_chrome::{protocol::page::ScreenshotFormat, Browser, LaunchOptionsBuilder};
let browser = Browser::new(LaunchOptionsBuilder::default().build().unwrap())?;
let png_data = browser.wait_for_initial_tab()?
    .wait_for_element("#mw-content-text > div > table.infobox.vevent")?

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

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

Scrolls the current element into view

Used prior to any action applied to the current element to ensure action is duable.

pub fn get_attributes(&self) -> Fallible<Option<NodeAttributes>>[src]

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

Get boxes for this element

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

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

Trait Implementations

impl<'a> Debug for Element<'a>[src]

Auto Trait Implementations

impl<'a> Send for Element<'a>

impl<'a> Unpin for Element<'a>

impl<'a> Sync for Element<'a>

impl<'a> UnwindSafe for Element<'a>

impl<'a> RefUnwindSafe for Element<'a>

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

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.