use of android.support.test.espresso.NoMatchingViewException in project appium-espresso-driver by appium.
the class Finder method handle.
@Override
public Element handle(Locator locator) throws AppiumException {
try {
if (locator.getUsing() == null) {
throw new InvalidStrategyException("Locator strategy cannot be empty");
} else if (locator.getValue() == null) {
throw new MissingCommandsException("No locator provided");
}
// Test the selector
ViewInteraction matcher = findBy(locator.getUsing(), locator.getValue());
matcher.check(matches(isDisplayed()));
// If we have a match, return success
return new Element(matcher);
} catch (NoMatchingViewException e) {
throw new NoSuchElementException("Could not find element with strategy " + locator.getUsing() + " and selector " + locator.getValue());
}
}
use of android.support.test.espresso.NoMatchingViewException in project android by tantecky.
the class SelectionActivityTest method getCurrentActivity.
private Activity getCurrentActivity() {
final Activity[] activity = new Activity[1];
onView(isRoot()).check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
activity[0] = (Activity) view.getContext();
}
});
return activity[0];
}
use of android.support.test.espresso.NoMatchingViewException in project AppCenter-SDK-Android by Microsoft.
the class EspressoUtils method waitFor.
public static ViewInteraction waitFor(final ViewInteraction viewInteraction, final long millis) throws InterruptedException {
final long startTime = System.currentTimeMillis();
final long endTime = startTime + millis;
final View[] found = new View[] { null };
while (System.currentTimeMillis() < endTime) {
try {
viewInteraction.check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
found[0] = view;
}
});
} catch (NoMatchingRootException ignored) {
}
if (found[0] != null)
return viewInteraction;
Thread.sleep(CHECK_DELAY);
}
Assert.fail();
return viewInteraction;
}
use of android.support.test.espresso.NoMatchingViewException in project TeamCityApp by vase4kin.
the class TestUtils method hasItemsCount.
/**
* https://gist.github.com/chemouna/00b10369eb1d5b00401b
*
* @param count
* @return
*/
public static ViewAssertion hasItemsCount(final int count) {
return new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException e) {
if (!(view instanceof RecyclerView)) {
throw e;
}
RecyclerView rv = (RecyclerView) view;
assertThat(rv.getAdapter().getItemCount(), is(count));
}
};
}
use of android.support.test.espresso.NoMatchingViewException in project storymaker by StoryMaker.
the class EndToEndTest method doTest.
public boolean doTest(String mediaString, String accountString) {
// obb file assumed to be present (test requires network access)
// select "new" option
onView(withText("New")).perform(click());
Timber.d("CLICKED NEW BUTTON");
// first selection
onView(withText("An Event")).perform(click());
Timber.d("CLICKED EVENT BUTTON");
// second selection
onView(withText("Show the best moments.")).perform(click());
Timber.d("CLICKED HIGHLIGHTS BUTTON");
// third selection
onView(withText(mediaString)).perform(click());
Timber.d("CLICKED MEDIA BUTTON");
// get liger activity
ActivityGetter ag = new ActivityGetter();
getInstrumentation().runOnMainSync(ag);
if (mMainActivity == null) {
Timber.e("NO LIGER ACTIVITY ACCESS");
return false;
}
// scroll to first capture card
// UPDATE IF STORY PATH CHANGES
ActivityScroller as1 = new ActivityScroller(4);
mMainActivity.runOnUiThread(as1);
stall(500, "WAIT FOR SCROLLING");
if (mediaString.equals("Video")) {
onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
Timber.d("CLICKED CAPTURE BUTTON");
stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
} else if (mediaString.equals("Audio")) {
// audio captured by the card itself, record a 10 second clip
onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
Timber.d("CLICKED CAPTURE BUTTON");
stall(10000, "WAIT FOR 10 SECONDS OF AUDIO");
onView(allOf(withText("STOP RECORDING"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
Timber.d("CLICKED STOP BUTTON");
stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
} else {
Timber.d("TEST DOES NOT HANDLE MEDIA TYPE " + mediaString);
return false;
}
// scroll to bottom
// UPDATE IF STORY PATH CHANGES
ActivityScroller as2 = new ActivityScroller(18);
mMainActivity.runOnUiThread(as2);
stall(500, "WAIT FOR SCROLLING");
// begin publish/upload steps
try {
onView(allOf(withText("Publish"), withParent(withTagValue(is((Object) "publish_card_1"))))).perform(click());
Timber.d("CLICKED PUBLISH BUTTON");
} catch (NoMatchingViewException nmve) {
// implies no button was found (failure)
Timber.d("NO PUBLISH BUTTON FOUND (FAIL)");
return false;
}
// enter metadata
onView(withId(R.id.fl_info_container)).perform(click());
Timber.d("CLICKED METADATA FIELD");
// get time for unique id
Calendar now = new GregorianCalendar();
onView(withId(R.id.et_story_info_title)).perform(clearText()).perform(typeText(mediaString.toUpperCase() + "/" + accountString.toUpperCase() + "/" + now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE)));
Timber.d("ENTERED TITLE TEXT");
pressBack();
stall(500, "PAUSE TO CLEAR KEYBOARD");
onView(withId(R.id.et_story_info_description)).perform(clearText()).perform(typeText(mediaString + "/" + accountString));
Timber.d("ENTERED DESCRIPTION TEXT");
pressBack();
stall(500, "PAUSE TO CLEAR KEYBOARD");
onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(mediaString.toLowerCase()));
onView(withId(R.id.btn_add_tag)).perform(click());
Timber.d("ENTERED FIRST TAG");
onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(accountString.toLowerCase()));
onView(withId(R.id.btn_add_tag)).perform(click());
Timber.d("ENTERED SECOND TAG");
pressBack();
stall(500, "PAUSE TO CLEAR KEYBOARD");
// these seem problematic, will troubleshoot later
/*
onView(withId(R.id.sp_story_section)).perform(click());
onView(withText("Travel")).perform(click());
Timber.d("SELECTED SECTION");
onView(withId(R.id.sp_story_location)).perform(click());
onView(withText("Czech Republic")).perform(click());
Timber.d("SELECTED LOCATION");
*/
onView(withText("Save")).perform(click());
Timber.d("SAVED METADATA");
// select account and upload
onView(withId(R.id.btnUpload)).perform(click());
Timber.d("CLICKED UPLOAD BUTTON");
// scroll to account
onView(withText(accountString)).perform(scrollTo(), click());
Timber.d("SCROLLED TO " + accountString + " BUTTON");
// only login on the first time through the loop
if ((accountString.equals("SoundCloud")) && (!soundcloudConnected)) {
// get name/password from xml file (add more later)
String accountName = "";
String accountPass = "";
if (accountString.equals("SoundCloud")) {
accountName = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_name);
accountPass = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_pass);
}
// enter name/password
onView(withId(R.id.etUsername)).perform(clearText()).perform(typeText(accountName));
Timber.d("ENTERED USER NAME");
pressBack();
stall(500, "PAUSE TO CLEAR KEYBOARD");
onView(withId(R.id.etPassword)).perform(clearText()).perform(typeText(accountPass));
Timber.d("ENTERED USER PASSWORD");
pressBack();
stall(500, "PAUSE TO CLEAR KEYBOARD");
onView(withId(R.id.btnSignIn)).perform(click());
Timber.d("CLICKED SIGN IN BUTTON");
soundcloudConnected = true;
} else {
Timber.d("ALREADY LOGGED IN TO " + accountString);
}
// onView(withId(R.id.switchStoryMaker)).perform(click());
Timber.d("CLICKED STORYMAKER PUBLISH SWITCH");
try {
// TODO: re-enable once test points to beta server
onView(withText("Continue")).perform(click());
Timber.d("CLICKED CONTINUE BUTTON");
} catch (NoMatchingViewException nmve) {
// implies no button was found (failure)
Timber.d("NO CONTINUE BUTTON FOUND (FAIL)");
return false;
}
// TODO: how to verify successful upload? (failure indicated by visible message)
stall(30000, "WAITING FOR UPLOAD");
Timber.d("TEST RUN COMPLETE (PASS)");
return true;
}
Aggregations