Struct Element

Source
pub struct Element<'a> { /* private fields */ }
Expand description

An HTML element within a WebDriver session.

Implementations§

Source§

impl<'a> Element<'a>

Source

pub fn new(s: &'a DriverSession, reference: String) -> Self

Source

pub fn attribute(&self, name: &str) -> Result<String, Error>

Source

pub fn property(&self, name: &str) -> Result<String, Error>

Return this element’s property value.

WebDriver spec: https://www.w3.org/TR/webdriver/#get-element-property

Source

pub fn click(&self) -> Result<(), Error>

Click this element.

WebDriver spec: https://www.w3.org/TR/webdriver/#element-click

Source

pub fn clear(&self) -> Result<(), Error>

Clear the text of this element.

WebDriver spec: https://www.w3.org/TR/webdriver/#element-clear

Source

pub fn send_keys(&self, s: &str) -> Result<(), Error>

Send key presses to this element.

WebDriver spec: https://www.w3.org/TR/webdriver/#element-send-keys

Source

pub fn css_value(&self, name: &str) -> Result<String, Error>

Source

pub fn text(&self) -> Result<String, Error>

Source

pub fn name(&self) -> Result<String, Error>

Returns the tag name for this element

Source

pub fn find_element( &self, selector: &str, strategy: LocationStrategy, ) -> Result<Element<'_>, Error>

Source

pub fn find_elements( &self, selector: &str, strategy: LocationStrategy, ) -> Result<Vec<Element<'_>>, Error>

Source

pub fn reference(&self) -> Result<JsonValue, Error>

Returns a reference that can be passed on to the API

Source

pub fn raw_reference(&self) -> &str

The raw reference id that identifies this element, this can be used with Element::new()

Source

pub fn inner_html(&self) -> Result<JsonValue, Error>

Gets the innerHTML javascript attribute for this element. Some drivers can get this using regular attributes, in others it does not work. This method gets it executing a bit of javascript.

Source

pub fn outer_html(&self) -> Result<JsonValue, Error>

Source

pub fn screenshot(&self) -> Result<Screenshot, Error>

Take a screenshot of this element

WebDriver specification: https://www.w3.org/TR/webdriver/#take-element-screenshot

Trait Implementations§

Source§

impl<'a> Debug for Element<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Element<'a>

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.