android-espresso

How do I detect a view that I have created programmatically in espresso

别说谁变了你拦得住时间么 提交于 2020-01-07 03:54:07
问题 I have this line of Espresso test code: onView(withId(R.id.rvWorkDaySchedule)).perform(swipeDown()); And rvWorkDaySchedule is shown in red in the editor of Android Studio because there is no such XML view id in the layouts - I create this RecyclerView programmatically. So how do I detect views that have been inflated programmatically with Espresso? 回答1: First of all, Espresso allows you to use Hamcrest matchers in tests. Hamcrest 1.3 Quick Reference. The most useful for catching the

What are the correct dependencies for Espresso tests?

独自空忆成欢 提交于 2020-01-06 07:01:41
问题 On different official Android sites there is different information on how to set up Espresso tests: 1) https://developer.android.com/training/testing/ui-testing/espresso-testing dependencies { // Other dependencies ... androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } 2) https://developer.android.com/studio/test/ dependencies { // Required for local unit tests (JUnit 4 framework) testCompile 'junit:junit:4.12' // Required for instrumented tests

How can I make Espresso test continue and NOT wait for an asynctask to complete?

两盒软妹~` 提交于 2020-01-06 06:51:55
问题 In my Android app - after a login there is a static Sync task that can potentially run for a few mins and it pulls data into the phone database. It's normal that the user can continue to use the app while it syncs down the data. But espresso for some reason it is waiting for the sync AsyncTask to fully finish before going to the next screen, how do I tell Espresso to continue and not wait? thanks 回答1: As stated in the documentation the call to onView() waits, among the other things, that

Espresso - Radio button, how to choose data

霸气de小男生 提交于 2020-01-06 06:19:11
问题 I'm using espresso for testing my android app. I have a radio group in my layout file <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioGroup android:id="@+id/radio_number_group" android:layout_width="match_parent" android:layout_height="wrap_content" /> </ScrollView> And radio button is added programmatically. The data is fetched from an API and added!! if (mvns.size() > 0) { radioGroup.removeAllViews(); for (String s : mvns) { RadioButton rb = new

Tapping the first matching text on a recycler view Android espresso Testing

别说谁变了你拦得住时间么 提交于 2020-01-05 07:32:50
问题 I am trying to tap on the first element of a matching text in my app. However at the moment i am receiving an error telling me there are multiple matches due to my current line of code. onView(allOf(withId(R.id.offerSummaryLayout))).perform(RecyclerViewActions.actionOnItem(Matchers.allOf(hasDescendant(withText("Online sale"))), click())); How can I change this so it clicks on the first matching element? Thanks in advance 回答1: If you have multiple matches and you only care about the first one,

Android espresso - How to check value of TextView at the bottom of Listview?

自古美人都是妖i 提交于 2020-01-05 06:51:27
问题 In the attached image above, it is a ListView having TextView (delivery report) Its status can be 'Sent' or 'Sending' or 'Failed' I want to check for 'Sent' condition which means assert message sent successfully As it is a conversation, newer messages will be at the bottom of the listview. What I've tried is... // Type the message ViewInteraction smsEditText = onView(withId(R.id.text_editor)).check(matches(isDisplayed())); smsEditText.perform(typeText("abcde")); closeSoftKeyboard(); Thread

Android espresso - How to check value of TextView at the bottom of Listview?

我的未来我决定 提交于 2020-01-05 06:51:12
问题 In the attached image above, it is a ListView having TextView (delivery report) Its status can be 'Sent' or 'Sending' or 'Failed' I want to check for 'Sent' condition which means assert message sent successfully As it is a conversation, newer messages will be at the bottom of the listview. What I've tried is... // Type the message ViewInteraction smsEditText = onView(withId(R.id.text_editor)).check(matches(isDisplayed())); smsEditText.perform(typeText("abcde")); closeSoftKeyboard(); Thread

How to let Espresso click a specific RecyclerView item?

五迷三道 提交于 2020-01-05 05:27:27
问题 I am trying to write an instrumentation test with Espresso for my Android app which uses a RecyclerView . Here is the main layout: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/grid" android:layout_width="match

How to let Espresso click a specific RecyclerView item?

喜夏-厌秋 提交于 2020-01-05 05:27:05
问题 I am trying to write an instrumentation test with Espresso for my Android app which uses a RecyclerView . Here is the main layout: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/grid" android:layout_width="match

Error inflating class Fragment when testing fragment using DataBinding

安稳与你 提交于 2020-01-04 06:39:08
问题 Can someone help me on this? In my test I want to check if the login button is displayed on the StartPage. I've been struggling with this error for a while today and I don't know how it should be resolved.What am I missing here? Maybe this problem is somehow similar to this question: Espresso test fails with java.lang.String cannot be cast to com.abc.events.databinding.SponsorDetailBinding android.view.InflateException: Binary XML file line #6: Error inflating class fragment at android.view