use of android.support.test.uiautomator.UiSelector in project android_frameworks_base by crdroidandroid.
the class UiBot method findDownloadRetryDialog.
public UiObject findDownloadRetryDialog() {
UiSelector selector = new UiSelector().text("Couldn't download");
UiObject title = mDevice.findObject(selector);
title.waitForExists(mTimeout);
return title;
}
use of android.support.test.uiautomator.UiSelector in project android_frameworks_base by crdroidandroid.
the class UiBot method chooseActivity.
/**
* Chooses a given activity to handle an Intent, using the "Just Once" button.
*
* @param name name of the activity as displayed in the UI (typically the value set by
* {@code android:label} in the manifest).
*/
// TODO: UI Automator should provide such logic.
public void chooseActivity(String name) {
// First check if the activity is the default option.
String shareText = "Share with " + name;
Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'");
boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout);
boolean justOnceHack = false;
if (gotIt) {
Log.v(TAG, "Found activity " + name + ", it's the default action");
clickJustOnce();
} else {
// Since it's not, need to find it in the scrollable list...
Log.v(TAG, "Activity " + name + " is not default action");
UiScrollable activitiesList = new UiScrollable(new UiSelector().scrollable(true));
try {
activitiesList.scrollForward();
} catch (UiObjectNotFoundException e) {
// TODO: for some paranormal issue, the first time a test is run the scrollable
// activity list is displayed but calling scrollForwad() (or even isScrollable())
// throws a "UiObjectNotFoundException: UiSelector[SCROLLABLE=true]" exception
justOnceHack = true;
Log.d(TAG, "could not scroll forward", e);
}
UiObject activity = getVisibleObject(name);
// ... then select it.
click(activity, name);
if (justOnceHack) {
clickJustOnce();
}
}
}
use of android.support.test.uiautomator.UiSelector in project coins-android by bubelov.
the class MainActivityTest method allowPermissionsIfNeeded.
private void allowPermissionsIfNeeded() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject allowPermissions = device.findObject(new UiSelector().text("ALLOW"));
if (allowPermissions.exists()) {
try {
allowPermissions.click();
} catch (UiObjectNotFoundException e) {
Timber.e(e, "Couldn't find dialog");
}
}
}
Aggregations