pub struct Element { /* private fields */ }
Expand description
WebElement
Provides methods to interact with page elements.
Implementations§
Source§impl Element
impl Element
Sourcepub fn find_element_from_self(
&self,
locator: LocatorStrategy,
) -> Result<Element, String>
pub fn find_element_from_self( &self, locator: LocatorStrategy, ) -> Result<Element, String>
Returns the first child element which is found using the locator.
Sourcepub fn find_elements_from_self(
&self,
locator: LocatorStrategy,
) -> Result<Vec<Element>, String>
pub fn find_elements_from_self( &self, locator: LocatorStrategy, ) -> Result<Vec<Element>, String>
Returns all children elements which are found using the locator.
pub fn is_selected(&self) -> Result<bool, String>
pub fn get_attribute(&self, attribute_name: &str) -> Result<String, String>
Sourcepub fn get_property(&self, property_name: &str) -> Result<String, String>
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
Sourcepub fn get_css_value(&self, css_property_name: &str) -> Result<String, String>
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
pub fn get_element_text(&self) -> Result<String, String>
pub fn get_tag_name(&self) -> Result<String, String>
Sourcepub fn get_element_rect(&self) -> Result<ElementRect, String>
pub fn get_element_rect(&self) -> Result<ElementRect, String>
Returns the element’s size(hight,width) and position(x-axis and y-axis)
pub fn is_enabled(&self) -> Result<bool, String>
Sourcepub fn get_computed_role(&self) -> Result<String, String>
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
Sourcepub fn get_computed_label(&self) -> Result<String, String>
pub fn get_computed_label(&self) -> Result<String, String>
See above
pub fn click(&self) -> Result<(), String>
Sourcepub fn clear_element(&self) -> Result<(), String>
pub fn clear_element(&self) -> Result<(), String>
Clears any element text
Sourcepub fn send_keys(&self, message: &str) -> Result<(), String>
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();