-2

I am working on automation testing of the Android app using Espresso. I am not able to perform click action on some image views on recycler view. I have tried to perform click by retrieving the required image view by going through its hierarchy but I am getting 'android.view.ViewRootImpl$CalledFromWrongThreadException' exception while performing click action which is working fine on other recycler views. I also tried to perform click by getting coordinates of the image view. I have tried some solutions through the following links:

Android Instrumentation Testing - UI Thread Issues Click by bounds / coordinates

1 Answers1

0

The problem has been solved. For this problem, I tried following steps to solve: 1. I retrieved the image view through its hierarchical view. 2. Created custom ViewAction method in which we are taking image view as an argument instead of id as shown in example 1 on the link given below. 3. Retrieved the root view by their id and passed the view action in its ViewAction part of espresso. https://www.programcreek.com/java-api-examples/index.php?api=android.support.test.espresso.action.GeneralClickAction