onData(anything()).inAdapterView(withId(R.id.ScheduleOrderListViewListView))
.atPosition(0).perform(click());
perfoms 50% of the time a longtouch - is there are a good workaround?
onData(anything()).inAdapterView(withId(R.id.ScheduleOrderListViewListView))
.atPosition(0).perform(click());
perfoms 50% of the time a longtouch - is there are a good workaround?
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 option you have of avoiding the issue is to run your tests on higher spec devices. This is because the likelihood of the issue occurring is dependent on system load.
Adding to what Charles said, I found 3 workarounds here: https://github.com/misyobun/android-test-kit/issues/45
Workaround 1: (and maybe the best one) is to pass a rollback action in case the click turns into a long click. In case this happened, the long click would be "cancelled" and espresso will try the click again.
Workaround 2: is not the "espresso way", but it might fit some scenarios:
Workaround 3: If you're not using double click on that view, it might be useful in this case.
I had this effect when animations where enabled. Animations must be disabled for espresso
Another additional workaround is running the following command on API level > 16