[−][src]Struct thirtyfour::WebElement
The WebElement struct encapsulates a single element on a page.
WebElement structs are generally not constructed manually, but rather they are returned from a 'find_element()' operation using a WebDriver.
Example:
let elem = driver.find_element(By::Name("input-result")).await?;
You can also search for a child element of another element as follows:
let elem = driver.find_element(By::Css("div[data-section='section-buttons']")).await?; let child_elem = elem.find_element(By::Tag("button")).await?;
Elements can be clicked using the click()
method, and you can send
input to an element using the send_keys()
method.
Fields
element_id: ElementId
Methods
impl<'a> WebElement
[src]
pub fn new(
conn: Arc<RemoteConnectionAsync>,
session_id: SessionId,
element_id: ElementId
) -> Self
[src]
conn: Arc<RemoteConnectionAsync>,
session_id: SessionId,
element_id: ElementId
) -> Self
Create a new WebElement struct.
Typically you would not call this directly. WebElement structs are usually constructed by calling one of the find_element*() methods either on WebDriver or another WebElement.
pub async fn rect<'_>(&'_ self) -> WebDriverResult<ElementRect>
[src]
Get the bounding rectangle for this WebElement.
pub async fn tag_name<'_>(&'_ self) -> WebDriverResult<String>
[src]
Get the tag name for this WebElement.
pub async fn text<'_>(&'_ self) -> WebDriverResult<String>
[src]
Get the text contents for this WebElement.
pub async fn click<'_>(&'_ self) -> WebDriverResult<()>
[src]
Click the WebElement.
pub async fn clear<'_>(&'_ self) -> WebDriverResult<()>
[src]
Clear the WebElement contents.
pub async fn get_property<'_, '_>(
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
[src]
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
Get the specified property.
pub async fn get_attribute<'_, '_>(
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
[src]
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
Get the specified attribute.
pub async fn get_css_property<'_, '_>(
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
[src]
&'_ self,
name: &'_ str
) -> WebDriverResult<String>
Get the specified CSS property.
pub async fn is_selected<'_>(&'_ self) -> WebDriverResult<bool>
[src]
Return true if the WebElement is currently selected, otherwise false.
pub async fn is_enabled<'_>(&'_ self) -> WebDriverResult<bool>
[src]
Return true if the WebElement is currently enabled, otherwise false.
pub async fn find_element<'_>(
&'_ self,
by: By<'a>
) -> WebDriverResult<WebElement>
[src]
&'_ self,
by: By<'a>
) -> WebDriverResult<WebElement>
Search for a child element of this WebElement using the specified selector.
Example:
let elem = driver.find_element(By::Css("div[data-section='section-buttons']")).await?; let child_elem = elem.find_element(By::Tag("button")).await?;
pub async fn find_elements<'_>(
&'_ self,
by: By<'a>
) -> WebDriverResult<Vec<WebElement>>
[src]
&'_ self,
by: By<'a>
) -> WebDriverResult<Vec<WebElement>>
Search for all child elements of this WebElement that match the specified selector.
Example:
let elem = driver.find_element(By::Css("div[data-section='section-buttons']")).await?; let child_elems = elem.find_elements(By::Tag("button")).await?; for child_elem in child_elems { assert_eq!(child_elem.tag_name().await?, "button"); }
pub async fn send_keys<'_, S>(&'_ self, keys: S) -> WebDriverResult<()> where
S: Into<TypingData>,
[src]
S: Into<TypingData>,
Send the specified input.
Example:
You can specify anything that implements Into<TypingData>
. This
includes &str and String.
elem.send_keys("selenium").await?;
You can also send special key combinations like this:
use thirtyfour::{Keys, TypingData}; elem.send_keys("selenium").await?; elem.send_keys(Keys::Control + "a").await?; elem.send_keys(TypingData::from("thirtyfour") + Keys::Enter).await?;
pub async fn screenshot_as_base64<'_>(&'_ self) -> WebDriverResult<String>
[src]
Take a screenshot of this WebElement and return it as a base64-encoded String.
pub async fn screenshot_as_png<'_>(&'_ self) -> WebDriverResult<Vec<u8>>
[src]
Take a screenshot of this WebElement and return it as PNG bytes.
pub async fn screenshot<'_, '_>(&'_ self, path: &'_ Path) -> WebDriverResult<()>
[src]
Take a screenshot of this WebElement and write it to the specified filename.
Trait Implementations
impl Clone for WebElement
[src]
fn clone(&self) -> WebElement
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for WebElement
[src]
impl Display for WebElement
[src]
impl Serialize for WebElement
[src]
Auto Trait Implementations
impl !RefUnwindSafe for WebElement
impl Send for WebElement
impl Sync for WebElement
impl Unpin for WebElement
impl !UnwindSafe for WebElement
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,