Java Code Examples for androidx.test.uiautomator.By#clazz()

The following examples show how to use androidx.test.uiautomator.By#clazz() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassInstancePair.java    From appium-uiautomator2-server with Apache License 2.0 5 votes vote down vote up
public BySelector getSelector() {
    String androidClass = getAndroidClass();

    //TODO: remove below comments once code get reviewed
    //below commented line related to UiAutomator V1(bootstrap) version, as we don't have possibility
    // in V2 version to use instance, so directly returning By.clazz
    // new UiSelector().className(androidClass).instance(Integer.parseInt(instance));
    return By.clazz(androidClass);
}
 
Example 2
Source File: CustomUiDevice.java    From appium-uiautomator2-server with Apache License 2.0 5 votes vote down vote up
@Nullable
private static BySelector toSelector(@Nullable AccessibilityNodeInfo nodeInfo) {
    if (nodeInfo == null) {
        return null;
    }
    final CharSequence className = nodeInfo.getClassName();
    return className == null ? null : By.clazz(className.toString());
}
 
Example 3
Source File: UiObjectMatcher.java    From device-automator with MIT License 5 votes vote down vote up
/**
 * Find a view based on it's class.
 *
 * @param klass The class of the view to find.
 * @return
 */
public static UiObjectMatcher withClass(Class klass) {
    UiSelector uiSelector = new UiSelector()
            .className(klass);
    BySelector bySelector = By.clazz(klass);

    return new UiObjectMatcher(uiSelector, bySelector);
}