Struct Element

Source
pub struct Element { /* private fields */ }
Expand description

WebElement

Provides methods to interact with page elements.

Implementations§

Source§

impl Element

Source

pub fn find_element_from_self( &self, locator: LocatorStrategy, ) -> Result<Element, String>

Returns the first child element which is found using the locator.

Source

pub fn find_elements_from_self( &self, locator: LocatorStrategy, ) -> Result<Vec<Element>, String>

Returns all children elements which are found using the locator.

Source

pub fn is_selected(&self) -> Result<bool, String>

Source

pub fn get_attribute(&self, attribute_name: &str) -> Result<String, String>

Source

pub fn get_property(&self, property_name: &str) -> Result<String, String>

Due to the large number of structure variants that may be returned by this function, parsing the String response to the necessary type is left for the lib users

Source

pub fn get_css_value(&self, css_property_name: &str) -> Result<String, String>

The logic behind returning json is the same as for get_property method

Source

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

Source

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

Source

pub fn get_element_rect(&self) -> Result<ElementRect, String>

Returns the element’s size(hight,width) and position(x-axis and y-axis)

Source

pub fn is_enabled(&self) -> Result<bool, String>

Source

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

As of 06.11.2020 computed role and computed label are not implemented by chrome and geckodrivers, so this method will only be returning errors for now

Source

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

See above

Source

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

Source

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

Clears any element text

Source

pub fn send_keys(&self, message: &str) -> Result<(), String>

Sends the text to the element if it is possibe for the element, otherwise, returns error

§Examples
let mut br = Browser::start_session(BrowserName::Chrome,  vec!["--headless","--window-size=400,200"]);
br.open("https://vk.com").unwrap();
let el= br.find_element(LocatorStrategy::CSS("#ts_input")).unwrap();
el.send_keys("Sup!").unwrap();
br.close_browser().unwrap();

Trait Implementations§

Source§

impl Debug for Element

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.