android-espresso

Intent resolved to different process in Espresso test for APK (without source code)

ぐ巨炮叔叔 提交于 2019-12-13 05:08:24
问题 I'm trying to launch an activity(of another APK) via instrumentation object. I'm able to pull the class of that APK in classToInvestigate object but cannot start the activity through instrumentation.startActivitySync(startIntent2); Below is the complete code of launching activity via instrumentation object. private Object xyz(String packageName, String className){ Object plugin = null; try { PackageManager packageManager = context.getPackageManager(); ApplicationInfo appInfo = packageManager

Espresso not uploading app apk to Firebase, getting message “Skipped triggering the test execution: The provided APK is invalid”

回眸只為那壹抹淺笑 提交于 2019-12-13 04:35:46
问题 I'm doing some automated testing using Espresso with Firebase, but when I run my test, when trying tu upload my test to Firebase, I get the message Skipped triggering the test execution: The provided APK is invalid, how can I solve it? 来源: https://stackoverflow.com/questions/58227597/espresso-not-uploading-app-apk-to-firebase-getting-message-skipped-triggering

Resources error when I add espresso-contrib

南楼画角 提交于 2019-12-13 03:44:05
问题 When I include espresso-contrib library to my gradle androidx.test.espresso:espresso-contrib:3.1.1 I have no problems syncing but when I try to run a test I get the following errors in the build: I can't go back to com.android.support as all my espresso dependencies are in androidX. I think it may be due to appcompat dependency on espresso-contrib. 回答1: Solved by setting compileSdkVersion to 28. Apparently you should do this if you migrate to AndroidX. 来源: https://stackoverflow.com/questions

Test text submit on SearchView when using Espresso

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 03:22:52
问题 How can I submit some text to SearchView in androidTest ? onView(withId(R.id.search_src_text)).perform(typeText("text")) doesn't work for me - app crashes at this line @Test fun testSearchViewTextSubmit() { ActivityScenario.launch(MainActivity::class.java) onView(withId(R.id.search_action)).perform(click()) // ok onView(withId(R.id.search_src_text)).perform(typeText("text")) // failed } androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.example

Check if a new Activity is started with Espresso by click on view

丶灬走出姿态 提交于 2019-12-13 03:01:05
问题 I have a button when click on this, start activity A. startActivityForResult(Intent(this, A::class.java) I need to check in an esspresso test when click on the button, start activity A or not? onView(withId(R.id.button)) .check(matches(isDisplayed())) .check(matches(isEnabled())) .perform(click()) // check is this A Activity start or not? 回答1: You can use espresso-intents package. First, try to add the latest version into your build.gradle : androidTestImplementation "androidx.test.espresso

Espresso - How to click on a random RecyclerView item?

眉间皱痕 提交于 2019-12-13 00:48:32
问题 There are a few posts that show how can you click a certain fixed item in the RecyclerView with Espresso, like: How to click on an item inside a RecyclerView in Espresso Using Espresso to click view inside RecyclerView item Example: //Change the 0 with any other number, will be the position of the item clicked. onView(withId(R.id.a_main_recycler)) .perform(RecyclerViewActions .actionOnItemAtPosition(0, click())); But, what if you want to click on a random item in the RecyclerView? 回答1: Use

AndroidTest Manifest permission not detected

佐手、 提交于 2019-12-12 19:16:41
问题 I have androidTest Manifest that has this permission: <uses-permission android:name="android.permission.SET_ANIMATION_SCALE" /> However, when I run the test, this permission is not set in my devDebug build. It only works when I add it to main/AndroidManifest.xml. Full androidTest/AndroidManifest.xml, <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.test.mobile"> <uses-sdk android:minSdkVersion="15" android

Check the font size, height, and width of the EditText with Espresso

帅比萌擦擦* 提交于 2019-12-12 19:15:51
问题 How could I check the font size, height, and width of an EditText with Espresso? At the moment to sect the text I use: onView(withId(R.id.editText1)).perform(clearText(), typeText("Amr")); And to read the text: onView(withId(R.id.editText1)).check(matches(withText("Amr"))); 回答1: You will have to create your own custom matchers since Espresso does not support any of these matchers by default. Luckily this can be done quite easily. Take a look at this example for font size: public class

Run espresso in ActivityInstrumentationTestCase2

谁都会走 提交于 2019-12-12 18:42:27
问题 I have written some test cases but when I try to include espresso in it, it shows java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation. I know I should migrate to junit 4 but I really dont want to change all the tests. Here is the test class: public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> { private Activity activity; public MainActivityTest() { super(MainActivity.class); } @Before protected void

Espresso test, click X/Y coordinates

狂风中的少年 提交于 2019-12-12 18:29:40
问题 Any idea how to do this for android? I can't seem to create a method that actually clicks. I know you can do it with onview, but I just want an x/y position. 回答1: The answer is already given here. public static ViewAction clickXY(final int x, final int y){ return new GeneralClickAction( Tap.SINGLE, new CoordinatesProvider() { @Override public float[] calculateCoordinates(View view) { final int[] screenPos = new int[2]; view.getLocationOnScreen(screenPos); final float screenX = screenPos[0] +