android-espresso

Android: how to use Espresso 2.2.2 with Support 25.0.0?

南楼画角 提交于 2020-01-04 06:15:44
问题 How can I get this working? I read many similar strategies, alas. Using a support lib higher than 23.1.1 fails times and again. dependencies { compile 'com.android.support:design:25.0.0' compile 'com.android.support:support-v4:25.0.0' compile files('libs/slf4j-android-1.5.8.jar') androidTestCompile 'com.android.support:support-annotations:25.0.0' androidTestCompile( 'com.android.support.test:rules:0.5') androidTestCompile( 'com.android.support.test.espresso:espresso-contrib:2.2.2')

Espresso test stuck/inactive after perform(click()) on button in ViewAnimator

前提是你 提交于 2020-01-03 08:25:06
问题 Problem: I'm having an issue while running my Espresso test, after the perform(click()) method is called on the login button, the test keeps running but doesn't go any further until 45 seconds pass and the test automatically fails. Meanwhile, the login happens normally. Context: I have an Activity with two Fragments side by side, the fragment on the right handles the username and password EditTexts and also the login button. This fragment is built with a ViewAnimator and two LinearLayouts as

Espresso test with “hasBackground”

China☆狼群 提交于 2020-01-03 02:22:15
问题 How can I make a espresso test with the color of the layout background? Currently use hasBackground(): onView(withId(R.id.backgroundColor)).check(matches(hasBackground(Color.parseColor("#FF55ff77")))); But the error occurs: android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'has background with drawable ID: -11141257' doesn't match the selected view. Expected: has background with drawable ID: -11141257 Got: "LinearLayout{id=2130968576, res-name

Controlling when an automation test ends - Espresso

元气小坏坏 提交于 2020-01-02 09:56:33
问题 I have an unusual situation I am testing. I am using Espresso to write my tests. I know Espresso and InstrumentationTestCase is not meant to do this. I have a Listener I created in one of my classes that will notify me of a change of a certain value. I use the listener in my test suite. When I get the value from the listener, I need to assert the value was changed as such. My problem is the test will end before I will receive the value form the listener. private void sendSpeedChanges() {

How to click on Android Gallery with Espresso

岁酱吖の 提交于 2020-01-02 02:35:09
问题 We currently have an Android application that we are testing with Espresso. One of the features we want to test is selecting a picture/image from the local image gallery. We can get all the way to bringing up the Gallery view, but then cannot select from Recent, Downloads, Gallery in the resulting window. A snippet as to how we got as far as we did is included below. public void testShouldBeAbleToSelectPhotoFromGallery() { getActivity(); // given onView(withId(launch_gallery_button)).perform

How to select a specific Tab position in Tab Layout using Espresso testing

拜拜、爱过 提交于 2020-01-01 12:12:13
问题 I have a tab layout with view pager .I am using Espresso for testing my android app. In my previous projects I use the tab title to perform click for selecting a tab Position like follows. Espresso.onView(ViewMatchers.withText("MAP")) .perform(ViewActions.click()); Right now I a have 114 tabs. So I can't use above method for randomly select these tabs for testing. Is there any way I can select tabs by its position. I already check other solutions but none of those helped me. 回答1: Should be

Android Espresso performs longClick instead of click

一笑奈何 提交于 2020-01-01 08:58:11
问题 onData(anything()).inAdapterView(withId(R.id.ScheduleOrderListViewListView)) .atPosition(0).perform(click()); perfoms 50% of the time a longtouch - is there are a good workaround? 回答1: This is an unfortunate side effect of how tap events are passed from your test code over RPC to the Android application under test. The best description of why clicks are sometimes executed as long clicks can be found in the Espresso source code. It is unlikely this issue will be fixed anytime soon. The best

Android Espresso - How to check EditText hint?

五迷三道 提交于 2020-01-01 07:31:08
问题 I'm starting to play with Espresso, got my basic tests running. Now trying to figure out how to check that my edit text has a specific hint text? Thanks. onView(withId(R.id.locationInput)).check(matches...?) 回答1: Since Espresso 2.0 just use internal ViewMatcher withHint : onView(withId(R.id.locationInput)).check(matches(withHint("your_hint"))) 回答2: Looks like I figured it out. Basically, you need to create your own matcher: public static Matcher<View> withHint(final String expectedHint) {

Espresso startActivity that depends on Intent

限于喜欢 提交于 2020-01-01 03:58:28
问题 I have the following situation. My activity has a fragment that depends of a Serializable Object. Here is my onCreate: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyObject myObj = (MyObj) getIntent().getSerializableExtra("myobj"); if(myObj != null) { FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.container, MyFragment.newInstance(myObj));

uninstall app before start test

試著忘記壹切 提交于 2020-01-01 03:40:12
问题 We're trying to write instrumentationTest for our app. For example I want to write test for authorization/registration. However before every test I want to be unauthorized? so I need to clean all data, delete db, etc. So is there any way to delete app or app's data before every test? 回答1: Use Annotations eg: @BeforeEach and put your clean up code there. 回答2: Using Android studio, you can create a test configuration that first uninstalls your app before running a test. Create a new External