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

source

pub fn id(id: &str) -> By

Native element identifier. resource-id for android; name for iOS.

source

pub fn name(name: &str) -> By

Name of element.

source

pub fn xpath(query: &str) -> By

Search the app XML source using xpath (not recommended, has performance issues).

source

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

source

pub fn android_data_matcher(query: &str) -> By

Locate an element using Espresso DataMatcher. (Espresso only)

source

pub fn android_view_matcher(query: &str) -> By

Locate an element using Espresso ViewMatcher. (Espresso only)

source

pub fn android_view_tag(query: &str) -> By

Locate an element by its view tag. (Espresso only)

source

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.

source

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)

source

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.

source

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)

source

pub fn image(base64_template: &str) -> By

Locate an element by matching it with a base 64 encoded image file

source

pub fn custom(query: &str) -> By

Custom locator for use with plugins registered via the customFindModules capability.

source

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.

Trait Implementations§

source§

impl Clone for By

source§

fn clone(&self) -> By

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for By

source§

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

Formats the value using the given formatter. Read more
source§

impl From<By> for LocatorParameters

source§

fn from(val: By) -> Self

Converts to this type from the input type.
source§

impl PartialEq for By

source§

fn eq(&self, other: &By) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for By

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for By

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more