Questions tagged [android-espresso]

1

votes
2

answer
39

Views

How to check if an element is to the right of another in android espresso?

I want to check if an element is to the right of another element using espresso. How to check it. A sample example would be helpful ViewInteraction textView = onView(allOf(withId(R.id.name), withText('dín'), childAtPosition(childAtPosition(IsInstanceOf.instanceOf(androidx.recyclerview.widget.Recycl...
Lijo Philip
1

votes
1

answer
91

Views

How to press default softkey using android espresso?

I need to fire search when the user press the default soft key button after filling SearchView. How do i simulate user pressing default soft key? Update As required, my code. The xml definition of the SearchText: The code: onView(withId(R.id.search_box)) .perform(typeSearchViewText('whatever query'...
ByteArtisan
1

votes
0

answer
307

Views

Espresso Tests cannot access class file & throwing various “package does not exist” errors

I got these multiple errors while doing the Module 7. Writing UI tests with Espresso of the Android Testing Code lab. I am using Android Studio 3.0 and these are the errors I am getting when I try to run the test: Gradle messages: Information:Gradle tasks [:app:assembleProdDebug, :app:assembleProdDe...
TheDancerCodes
1

votes
0

answer
23

Views

I am unable to run espresso tests in Android version 7 and above

I am unable to run espresso tests on android emulators or devices with Android version 7 and above. I get the following error as soon as the tests start: java.lang.NoSuchFieldError: No static field EXACT of type Lcom/google/common/collect/ImmutableMap; in class Lcom/google/thirdparty/publicsuffix/Pu...
1

votes
0

answer
113

Views

Fragment Not Associated With A Fragment Manager

I am writing some instrumented tests for an app with one activity and multiple fragments using the Navigation Component. The code for my splash screen is as below: class SplashFragment : Fragment(), KodeinAware { override val kodein by Admin.instance.kodein private var realm: Realm? = null override...
Alex Kombo
1

votes
0

answer
80

Views

How to get a text from a DataInteraction object

I am testing an android application in which I want to retrieve the text from a datainteraction object. Is there any code to do the same. Below is the sample code which i did. onData(anything()).inAdapterView(withId(R.id.procedureListView)).atPosition(i).onChildView(withId(R.id.workOrderStatus))).to...
Deepak
1

votes
1

answer
171

Views

android espresso webview access element in iframe

This time I try to use espresso to test my app. I use webview to open the url and check below html code I face the question that I can`t access the element in iframe. I copy the XPTH that is /html/body/button and code onWebView().withElement(findElement(Locator.XPATH, '/html/body/button')).perform(...
呂裕翔
1

votes
0

answer
46

Views

[Android][Espresso] AppNotIdle Exception: how to find running UI/Main thread?

When I am running Espresso in android,it has an error: Caused by: android.support.test.espresso.AppNotIdleException: Looped for 3762 iterations over 60 SECONDS. The following Idle Conditions failed . After I google it, I found the reason because the main/ui thread is not idle. So I use the below cod...
user3239558
1

votes
3

answer
274

Views

Descriptions for ViewAssertion in Espresso

I have this code: onView(withId(R.id.my_view)).check(matches(isDisplayed())) How can I add my own message to it in case of a fall of the test with an error? For example as in junit: assertEquals('My message', expected, actual)
Hamster
1

votes
1

answer
261

Views

Espresso Assertion Failed With Cause Error

I have been trying to run a test on espresso, which will give input to editText and will hit a button and then it goes for validation, I have included dependencies tried clearing cache but still facing this error Here is the test @RunWith(AndroidJUnit4.class) public class Espresso { @Rule public Act...
Nirav Jadeja
1

votes
1

answer
207

Views

Android Espresso tests won't run after upgrading to 3.0.1 android gradle plugin

I have just upgraded to com.android.tools.build:gradle:3.0.1 and latest Android Studio stable version(3.0.1) and suddenly my espresso tests won't run. I get the following error and don't have any idea about what it means. Any suggestions? [Device]: Error during Sync: Broken pipe com.android.ddmlib.I...
mbob
1

votes
1

answer
472

Views

Espresso Test Fail due to App not Idle Exception: The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED

My Espresso test is working fine with Espresso version 2.2.2 but When I update my studio to latest one and applied migration rule test going to fail and required to update the version. library using androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'com...
Hussain Sherwani
1

votes
1

answer
331

Views

Idling Resource not working in second activity in android

I have two Activities A and B. I am running a background thread for 500ms and update a TextView. Once the TextView is updated, I click on the TextView to go to B Activity. In Activity B I have another background thread which is running for 500ms and update a TextView in the B Activity. I am testing...
XoXo
1

votes
0

answer
66

Views

How to use Espresso's intenting with DocumentsProvider results

My activity needs to request a new document from a document provider. I want to test this in my espresso test by intenting an activity result with a uri. However, the returned uri does not have the correct permissions granted. At least I get a SecurityException: No persistable permission grants foun...
friedger
1

votes
0

answer
174

Views

UI test : Wait for user input while running an instrumentation test

Is it possible to wait for user input like users mobile no or otp in an instrumentation test. I can hard code the mobile no. but the otp is not in my control. If its not possible how should we test such flows?
sanket vetkoli
1

votes
1

answer
194

Views

Firebase test lab showing unexpected test failures

I've started using Firebase Test Lab recently with espresso. All the test cases pass on my local device but when it comes to testing devices present on google cloud, some test cases fail with exceptions like 'NoMatchingViewException'. I've tried increasing the wait time before the test runs and the...
Abhimanyu Kaushal
1

votes
0

answer
37

Views

Can we send data to an espresso test

So I am implementing a custom idling resource and I am wondering, is it possible to have the UI send data to espresso tests with data about is causing my idling resource to increment? Can I create another callback that is run when my IdlingResource is idle that sends to my test?
punk_fusion92
1

votes
0

answer
72

Views

Location of espresso test reports into files created dynamically

Currently, all my test reports are being created and stored in the folder 'test-reports' in the project root directory. Below is the gradle file, in which I have specified the directory under 'testOptions'. android { compileSdkVersion 26 defaultConfig { applicationId 'com.example.edk1kor.decodedemov...
Deeksha Kamath
1

votes
0

answer
54

Views

Espresso non launcher activity test

Is is possible to test a non launcher activity in isolation using espresso? If not then how do you propose testing UI for all the activities of an app? I am using ActivityTestRule to start the activity being tested but my activity gets destroyed immediately after it is created.
VIR474
1

votes
1

answer
71

Views

Espresso: returning to application

I have test in Espresso, at the end of the test I press call button in application, which leads to dialing screen of the phone. How can I return back to application? I want to return to application to log out from it. pressBack(); doesn't do anything. Suggestions would be appreciated.
president
1

votes
1

answer
101

Views

How to put test data files on a device for instrumental tests?

What is the best/proper way to upload the test data files onto the device before the instrumentation (Espresso) tests? I want to test app functionality when a user selects some files on the device file system and my app are processing these files and prepare the app state for further functional test...
engilyin
1

votes
0

answer
91

Views

Espresso Test Output Truncated in Console, How to Get Full Results?

When outputting test failures with multiple lines, I've found that Gradle and the Android Plugin truncate results. For example, if an exception message has 12 lines, only 3 will display in the console. The other 12 lines, along with the stack trace, end up in the generated HTML and XML results files...
Danielle
1

votes
1

answer
230

Views

When running espresso tests, app resumes instead of restarting

When I run multiple espresso tests, I find that the app does not restart but starts from the same location that it is left off. How to make it start from the beginning everytime
punk_fusion92
1

votes
0

answer
153

Views

How to mock a connectivityManager without mock context in espresso

I'm writing espresso test which requires wifi connection, just need to get connectivityManager.isActiveNetworkMetered() return false in emulator. I think mock a connectivityManager is a way, but I cannot mock the application context in my test, is there any other way to implement it?
Pineapple
1

votes
0

answer
75

Views

How to test RecyclerView in Espresso?

I've worked with Android for a while, but I'm fairly new to Test Driven Develeopment in Android. I'm trying to test - when I type any text to the EditText, the RecyclerView shows some data from the server using the text I typed. In real application, I'll receive data for the RecyclerView from the re...
Tura
1

votes
1

answer
135

Views

Record Espresso Test For Two InstantApp Modules

PROBLEM: An instantapp activity from one module (base) calls activity from another module (my_feature). Both should be tested using 'Record Espresso Test' in Android Studio. RESEARCH: Espresso-generated code for non-instant application has R.id.component references on both activities. In an instant-...
Zon
1

votes
1

answer
512

Views

Android Test if toast is shown

I am writing a test to check if a custom Toast is being shown. The Toast is not being constructed and shown in an Activity instance. I have a created a class that has access to the Context. public class ToastHandler{ private Context context; public ToastHander(Context context){ this.context = contex...
LonsomeHell
1

votes
0

answer
111

Views

NoClassDefFoundError when trying to run android espresso tests

I've added the dependencies and it always crash with java.lang.NoClassDefFoundError: android.support.test.espresso.base.BaseLayerModule_ProvideFailureHanderFactory androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test:rules:0.5' androidTestCompile 'com...
Diego Plentz
1

votes
1

answer
29

Views

Create and launch Espresso test

Is there a way to create an espresso test file from a class like does Command / Control+Shift+T? Same for launch the current test with espresso into the device? It's very annoying to create/launch every test manually through the whole process of going to the file's hierarchy and then create the laun...
crgarridos
1

votes
0

answer
227

Views

Espresso Testing 'Process Crashed' immediately when using ProGuard

I've got a rather large project for which I've written a test suite. When running the tests on a build that is not minified, the tests run fine. Once I set minifyEnabled to true on the buildType I'm using, the tests immediately fail with the following message: Started running tests Test running fai...
LukeWaggoner
1

votes
0

answer
117

Views

Android. Espresso: android.content.res.Resources$NotFoundException: String resource ID

Android Studio 3.1. , Java 1.8. , Gradle 4.4. Here my Espresso test: @RunWith(AndroidJUnit4.class) public class SignInActivityTest { private Context context; @Rule public ActivityTestRule mActivityRule = new ActivityTestRule(SignInActivity.class, true, false); private MockWebServer server; @Before p...
Alexei
1

votes
1

answer
229

Views

Testing ListView with Espresso by finding its objects within the adapter

I have a custom matcher used to test that some data exists in a ListView. It find all the objects kept by the listview adapter: private static Matcher checkStringInList(final Matcher expected) { return new BoundedMatcher(MyObject.class) { @Override public boolean matchesSafely(final MyObject actualO...
mbob
1

votes
1

answer
340

Views

Espresso not finding test apk

Im building a test suite for my app, but keep getting the following error when trying to run a test on an emulator: $ adb push /Users/me/dev/Android/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/myApp.debug $ adb shell pm install -t -r '/data/local/tmp/myApp.debug' pkg: /data/local/tmp/m...
davy307
1

votes
3

answer
259

Views

How to mock after setup dagger-android 2.15 when writing espresso tests?

If we just use plain dagger 2. In the application class, we will have a property which holds the AppComponent. Then we can swap it during espresso tests. But when I setup my project using dagger-android 2.15. Things becomes more implicit if adopt too much Dagger magic. The code is more clean, but ma...
Albert Gao
1

votes
0

answer
189

Views

Unable to test code requiring CHANGE_NETWORK_STATE / WRITE_SETTINGS permission on Marshmallow

I am trying to upgrade my app's targetSDK to above 23 and I've run into a small problem. I have an activity that binds traffic to Wifi (to measure the network speed to the router, even if the router is not connected to the internet). In order for that to happen my app needs the CHANGE_NETWORK_STATE...
Emil S.
1

votes
0

answer
215

Views

Espresso won't wait for mock response with custom Interceptor

I'm writing an UI test which includes Espresso and Retrofit. My espresso won't wait for my fake API to draw all the data before clicking the next button. I created a custom class like this to make mock response: public class FakeInterceptor implements Interceptor { private final static String TAG =...
Tran Hoai Nam
1

votes
0

answer
165

Views

Firebase Test Lab Instrumentation Test Fails At Google Signin

I implemented an app that connects to Google Calendar API to read calendar event of a user. i've been trying to test my application using the Firebase Android Instrumentation Test feature. The features that doesn't require a Login such as home screen were tested and passed just fine. I have not impl...
user3645709
1

votes
0

answer
425

Views

Espresso unable to launch another activity

Espresso unable to find second activity. I am trying out a simple test with Espresso calling a new activity but it always fails with the error log below. What am I to do rightly? This is the test class public class LoginActivityTest { @Rule public ActivityTestRule mActivityTestRule = new ActivityTes...
kehinde
1

votes
1

answer
163

Views

Is it possible to use Espresso to test app with AndroidForWork work profile

I want to test MyApp by Espresso. MyApp can do AndroidForWork enrollment. After enrollment there will be 2 MyApps on device: one is with personal profile and the other is with work profile like below: (I just use Download app as an example.) app with personal profile and work profile My question: Is...
MxJ
1

votes
0

answer
154

Views

Test image is loaded by Picasso with Espresso

I'm developing an android application and i'm trying to test one screen that shows a list of elements. The list is implemented using a RecyclerView and each item has a name (TextView) and an image (ImageView). For testing first element name, i use the next code: private static int ANY_ELEMENT_POSIT...

View additional questions