Click on not fully visible imageButton with Espresso

前端 未结 7 1119
臣服心动
臣服心动 2021-01-31 09:05

I have a custom ImageButton that is not fully visible, by design, so when I perform a click action I get this error:

android.support.test.espresso.P         


        
7条回答
  •  被撕碎了的回忆
    2021-01-31 09:43

    Default click of Espresso is requiring visibility of view > 90%. What do you think about creating an own click ViewAction? Like this...

    public final class MyViewActions {
       public static ViewAction click() {
          return new GeneralClickAction(SafeTap.SINGLE, GeneralLocation.CENTER, Press.FINGER);
        }
    }
    

    This click will click on the center of your view.

    Then you could execute click like this: onView(withId(....)).perform(MyViewActions.click());

    I hope it could work.

提交回复
热议问题