pub enum By {
Css(String),
XPath(String),
Text(String),
PartialText(String),
Id(String),
Tag(String),
Name(String),
Class(String),
LinkText(String),
PartialLinkText(String),
}Expand description
Element locator strategy (like Selenium’s By).
Supports multiple strategies for finding elements in the DOM.
Variants§
Css(String)
CSS selector (most common).
§Example
ⓘ
By::Css("#login-button")
By::Css("button.primary")
By::Css("[data-testid='submit']")XPath(String)
XPath expression.
§Example
ⓘ
By::XPath("//button[@type='submit']")
By::XPath("//div[contains(@class, 'modal')]")
By::XPath("//a[text()='Login']")Text(String)
Exact text content match.
Finds element where textContent.trim() === value.
§Example
ⓘ
By::Text("Submit")
By::Text("Click here to continue")PartialText(String)
Partial text content match.
Finds element where textContent.includes(value).
§Example
ⓘ
By::PartialText("Submit")
By::PartialText("continue")Id(String)
Element ID (shorthand for #id CSS selector).
§Example
ⓘ
By::Id("username") // equivalent to By::Css("#username")Tag(String)
Name(String)
Class(String)
Class name (single class).
§Example
ⓘ
By::Class("btn-primary") // equivalent to By::Css(".btn-primary")LinkText(String)
PartialLinkText(String)
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for By
impl<'de> Deserialize<'de> for By
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for By
impl StructuralPartialEq for By
Auto Trait Implementations§
impl Freeze for By
impl RefUnwindSafe for By
impl Send for By
impl Sync for By
impl Unpin for By
impl UnwindSafe for By
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.