Enum appium_client::find::By
source · pub enum By {
Show 14 variants
Id(String),
Name(String),
Xpath(String),
UiAutomator(String),
AndroidDataMatcher(String),
AndroidViewMatcher(String),
AndroidViewTag(String),
IosClassChain(String),
IosNsPredicate(String),
AccessibilityId(String),
ClassName(String),
Image(String),
Custom(String),
CustomKind(String, String),
}
Expand description
Locators supported by Appium
If you wish to use your very own locator (e.g. something I didn’t implement in this enum), just use By::CustomKind.
Variants§
Id(String)
Name(String)
Xpath(String)
UiAutomator(String)
AndroidDataMatcher(String)
AndroidViewMatcher(String)
AndroidViewTag(String)
IosClassChain(String)
IosNsPredicate(String)
AccessibilityId(String)
ClassName(String)
Image(String)
Custom(String)
CustomKind(String, String)
Implementations§
source§impl By
impl By
sourcepub fn xpath(query: &str) -> By
pub fn xpath(query: &str) -> By
Search the app XML source using xpath (not recommended, has performance issues).
sourcepub fn uiautomator(query: &str) -> By
pub fn uiautomator(query: &str) -> By
Use the UI Automator API, in particular the UiSelector class to locate elements. (UiAutomator2 only).
In Appium you send the Java code, as a string, to the server, which executes it in the application’s environment, returning the element or elements.
See https://developer.android.com/reference/androidx/test/uiautomator/UiSelector
sourcepub fn android_data_matcher(query: &str) -> By
pub fn android_data_matcher(query: &str) -> By
Locate an element using Espresso DataMatcher. (Espresso only)
sourcepub fn android_view_matcher(query: &str) -> By
pub fn android_view_matcher(query: &str) -> By
Locate an element using Espresso ViewMatcher. (Espresso only)
sourcepub fn android_view_tag(query: &str) -> By
pub fn android_view_tag(query: &str) -> By
Locate an element by its view tag. (Espresso only)
sourcepub fn ios_class_chain(query: &str) -> By
pub fn ios_class_chain(query: &str) -> By
Locate an element by a class chain - a faster, but less powerful alternative to XPath on iOS.
sourcepub fn ios_ns_predicate(query: &str) -> By
pub fn ios_ns_predicate(query: &str) -> By
A string corresponding to a recursive element search using the iOS Predicate. (iOS 10.0 and above)
sourcepub fn accessibility_id(id: &str) -> By
pub fn accessibility_id(id: &str) -> By
Read a unique identifier for a UI element.
For XCUITest it is the element’s accessibility-id attribute. For Android it is the element’s content-desc attribute.
sourcepub fn class_name(class_name: &str) -> By
pub fn class_name(class_name: &str) -> By
Locate element by its class name.
For IOS it is the full name of the XCUI element and begins with XCUIElementType. For Android it is the full name of the UIAutomator2 class (e.g.: android.widget.TextView)
sourcepub fn image(base64_template: &str) -> By
pub fn image(base64_template: &str) -> By
Locate an element by matching it with a base 64 encoded image file
sourcepub fn custom(query: &str) -> By
pub fn custom(query: &str) -> By
Custom locator for use with plugins registered via the customFindModules capability.
sourcepub fn custom_kind(using: &str, value: &str) -> By
pub fn custom_kind(using: &str, value: &str) -> By
A locator for non-standard locators
You can define what type of locator to use, so you’re free to use anything here.