android-espresso

Is it possible to disable Toasts or wait until toast disappears while testing

社会主义新天地 提交于 2019-12-30 09:13:49
问题 I am testing an app with Espresso . I have one question is it possible to wait until there are no toast are currently being showed. I have a lot of different toast in my app, but while testing I have problems with them because as far as I can guess focus is gone to the toast and I am getting quite another view hierarchy as I can see in error logs. So my question is it possible to hide all (system wide with root access) or just wait until there are any toasts on the screen or maybe if it is

Assert proper number of items in list with espresso

ぐ巨炮叔叔 提交于 2019-12-30 08:26:50
问题 What is the best way to inspect and assert that a listview is the expected size with android espresso? I wrote this matcher, but don't quite know how to integrate it into the test. public static Matcher<View> withListSize (final int size) { return new TypeSafeMatcher<View> () { @Override public boolean matchesSafely (final View view) { return ((ListView) view).getChildCount () == size; } @Override public void describeTo (final Description description) { description.appendText ("ListView

Espresso NestedScrollView

為{幸葍}努か 提交于 2019-12-30 08:15:10
问题 I am trying to test EditTexts in my form that are within a NestedScrollView. I am running the following code: onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click()); where register_scroll_view is my NestedScrollView. However, I am getting an exception: android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: com.eazyigz.myapp:id/register_scroll_view'. Caused by: java.lang.RuntimeException: Action will not be performed because the

Espresso NestedScrollView

三世轮回 提交于 2019-12-30 08:15:09
问题 I am trying to test EditTexts in my form that are within a NestedScrollView. I am running the following code: onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click()); where register_scroll_view is my NestedScrollView. However, I am getting an exception: android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: com.eazyigz.myapp:id/register_scroll_view'. Caused by: java.lang.RuntimeException: Action will not be performed because the

how to get text from textview using espresso

三世轮回 提交于 2019-12-30 02:45:10
问题 I want get text string shown in a textview in LinearLayout. can espresso do that? If not, is there other way to do that or can I use android api in espresso test case? I am using API 17 18 or newer, espresso 1.1(It should be the latest one.). I have no clue about this. Thanks. 回答1: The basic idea is to use a method with an internal ViewAction that retrieves the text in its perform method. Anonymous classes can only access final fields, so we cannot just let it set a local variable of getText(

Android Espresso wait for text to appear

若如初见. 提交于 2019-12-29 08:28:07
问题 I am trying to automate Android app, that is a chat bot, using Espresso. I can say that I am completely new with android app automation. Right now I am struggled with waiting. If I use thread.sleep it works perfectly fine. But I would like to wait for specific text to appear on the screen - how I can do that? @Rule public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class); @Test public void loginActivityTest() { ViewInteraction loginName = onView

Click by bounds / coordinates

梦想的初衷 提交于 2019-12-28 06:17:29
问题 I know it is possible for Espresso to click by bounds the way UiAutomator does. (x and y coordinates) I have read through the documentation but I can't seem to find it. Any help is appreciated. Thanks Edit I found this link, but no examples how to use it, My main concern with this is the UiController is or how to use it. 回答1: Espresso has the GeneralClickAction, this is the underlying implementation of ViewActions click() , doubleClick() , and longClick() . The GeneralClickAction 's

JUnit/Espresso: “empty test suite”

允我心安 提交于 2019-12-28 04:34:11
问题 Far too often in Android Studio I run into this problem: I can run the entire suite of UI Tests just fine, but cannot run a single file or a single test case. When I try, I will get an error such as: Process finished with exit code 1 Class not found: "com.example.MyTest"Empty test suite. 回答1: It's a hassle, but I have found a solution. Go to Edit Configurations... Add a new test configuration manually. Make sure to select Android Instrumented Tests Type in a name for this configuration -

Espresso.onData set inAdapterView to be AlertDialog

試著忘記壹切 提交于 2019-12-25 09:22:25
问题 I have an AlertDialog that contains a list of options which is set: final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) .setTitle(args.getString(TITLE)) .setSingleChoiceItems(ARRAY_OF_CHARSEQUENCE, args.getInt(SELECTED_INDEX), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // handle click dismiss(); } }); I am trying to test clicking on each item. If I run: onView(allOf(withClassName(Matchers.equalTo

android espresso : total count of elements with samerid not in adapter view

邮差的信 提交于 2019-12-25 07:38:04
问题 I am trying to get the count of elements with same rid The solutions here How to get count of items with same ids which are not in adapter view is not helping me. static int counter = 0; public static Matcher<View> withIdAndDisplayed(final int id) { Checks.checkNotNull(id); return new TypeSafeMatcher<View>() { @Override public void describeTo(Description description) { description.appendText("with item id: " + id); } @Override public boolean matchesSafely(View view) { if ((view.getId() == id)