use of android.support.test.espresso.ViewInteraction in project chefly_android by chef-ly.
the class FavoriteNavgationTest method favoriteNavgationTest.
@Test
public void favoriteNavgationTest() {
ViewInteraction appCompatButton = onView(allOf(withId(R.id.skipBtn), withText("Skip"), isDisplayed()));
appCompatButton.perform(click());
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction appCompatTextView = onView(allOf(withId(R.id.continueAsGuest), withText("Skip"), withParent(allOf(withId(R.id.activity_main), withParent(withId(android.R.id.content)))), isDisplayed()));
appCompatTextView.perform(click());
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction appCompatImageButton = onView(allOf(withContentDescription("Open navigation drawer"), withParent(withId(R.id.toolbar)), isDisplayed()));
appCompatImageButton.perform(click());
ViewInteraction appCompatCheckedTextView = onView(allOf(withId(R.id.design_menu_item_text), withText("Contact Us"), isDisplayed()));
appCompatCheckedTextView.perform(click());
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
pressBack();
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction appCompatImageButton2 = onView(allOf(withId(R.id.favBtn), withContentDescription("Favorite"), withParent(childAtPosition(withId(R.id.list), 0)), isDisplayed()));
appCompatImageButton2.perform(click());
ViewInteraction appCompatTextView2 = onView(allOf(withId(R.id.favortiesHeader), withText("Favorites"), isDisplayed()));
appCompatTextView2.perform(click());
ViewInteraction viewPager = onView(allOf(withId(R.id.viewpager), withParent(withId(R.id.activity_recipe_list)), isDisplayed()));
viewPager.perform(swipeLeft());
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction appCompatImageButton3 = onView(allOf(withContentDescription("Open navigation drawer"), withParent(withId(R.id.toolbar)), isDisplayed()));
appCompatImageButton3.perform(click());
ViewInteraction appCompatCheckedTextView2 = onView(allOf(withId(R.id.design_menu_item_text), withText("Ingredients Search"), isDisplayed()));
appCompatCheckedTextView2.perform(click());
}
use of android.support.test.espresso.ViewInteraction in project appium-espresso-driver by appium.
the class SendKeys method handle.
@Override
@Nullable
public Void handle(TextParams params) throws AppiumException {
String id = params.getElementId();
ViewInteraction viewInteraction = Element.getById(id);
// Convert the array of text to a String
String[] textArray = params.getValue();
StringBuilder stringBuilder = new StringBuilder();
for (String text : textArray) {
stringBuilder.append(text);
}
String textValue = stringBuilder.toString();
try {
viewInteraction.perform(typeText(textValue));
} catch (PerformException e) {
throw new AppiumException("Could not apply sendKeys to element " + id + ": " + e.getMessage());
}
return null;
}
use of android.support.test.espresso.ViewInteraction in project dagger-test-example by aschattney.
the class SimpleTest method itShouldShowWeatherForNextDay.
@Test
public void itShouldShowWeatherForNextDay() throws IOException {
doReturn(Observable.empty()).when(weatherApi).getCurrentWeather(anyDouble(), anyDouble(), anyString(), anyString(), anyString());
doReturn(Observable.empty()).when(weatherApi).getTomorrowWeather(anyDouble(), anyDouble(), anyString(), anyInt(), anyString(), anyString());
when(weatherApi.getForecastWeather(eq(FAKE_LONGITUDE), eq(FAKE_LATITUDE), eq("metric"), eq("de"), anyString())).thenReturn(Observable.just(jsonToPojo(ThreeHoursForecastWeather.class, Responses.THREE_HOUR_FORECAST)));
mActivity = rule.launchActivity(null);
allowPermissionsIfNeeded();
ViewInteraction appCompatTextView = onView(allOf(withText(R.string.tomorrow), isDisplayed()));
appCompatTextView.perform(click());
ViewInteraction appCompatImageView = onView(allOf(withId(R.id.imageView), isDisplayed()));
appCompatImageView.perform(click());
String threeHourForecastDataAsString = "2017-01-23 00:00:00: -11.55°C\n" + "2017-01-23 03:00:00: -12.0°C\n" + "2017-01-23 06:00:00: -12.15°C\n" + "2017-01-23 09:00:00: -11.34°C\n" + "2017-01-23 12:00:00: -8.84°C\n" + "2017-01-23 15:00:00: -7.94°C\n" + "2017-01-23 18:00:00: -9.35°C\n" + "2017-01-23 21:00:00: -10.29°C\n";
ViewInteraction textView = onView(withId(R.id.textView));
textView.check(matches(withText(threeHourForecastDataAsString)));
ViewInteraction textView2 = onView(withId(R.id.textView6));
textView2.check(matches(withText("Three Hour Forecast")));
}
Aggregations