use of android.support.test.espresso.NoMatchingViewException in project storymaker by StoryMaker.
the class MinimumTest 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");
// media capture
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");
// 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");
// 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");
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;
}
use of android.support.test.espresso.NoMatchingViewException in project apps-android-wikipedia by wikimedia.
the class ExploreFeedTest method setStaticCardDate.
private static void setStaticCardDate() {
try {
ViewInteraction colorButton = onView(allOf(ViewTools.matchPosition(allOf(withId(R.id.view_static_card_subtitle)), 0), isDisplayed()));
colorButton.perform(setTextInTextView("Main page on Feb 5, 2017"));
} catch (NoMatchingViewException | PerformException e) {
return;
}
}
use of android.support.test.espresso.NoMatchingViewException in project apps-android-wikipedia by wikimedia.
the class ExploreFeedTest method setDate.
private static void setDate() {
try {
for (int i = 0; i < 3; i++) {
ViewInteraction colorButton = onView(allOf(ViewTools.matchPosition(allOf(withId(R.id.view_card_header_subtitle)), i), isDisplayed()));
colorButton.perform(setTextInTextView("Feb 5, 2017"));
}
} catch (NoMatchingViewException | PerformException e) {
return;
}
}
use of android.support.test.espresso.NoMatchingViewException in project apps-android-wikipedia by wikimedia.
the class HistoryTabTest method setDate.
private static void setDate() {
try {
for (int i = 0; i < 3; i++) {
ViewInteraction colorButton = onView(allOf(ViewTools.matchPosition(allOf(withId(R.id.page_list_header_text)), i), isDisplayed()));
colorButton.perform(setTextInTextView("Feb 5, 2017"));
}
} catch (NoMatchingViewException | PerformException e) {
return;
}
}
Aggregations