Clicking button on second activity got error performing 'single click' or 'scroll to' on view

后端 未结 2 560
夕颜
夕颜 2020-12-17 07:40

Clicking a button in Espresso test got problem. Let\'s say I have two activities \"Activity1\" and \"Activity2\". Click a dialog OK button in Activity1 starts Activity2 wher

2条回答
  •  醉梦人生
    2020-12-17 08:02

    The solution is to create your custom GeneralClickAction with view visibility that you want to click less then Espresso's GeneralClickAction requires. Currently the minimum visibility value is 90% - see code here line 60. Set it to be 80% or less. Just copy the whole class rename it and change the value provided to this method to 80 isDisplayingAtLeast(80). Then create your click action that uses your custom GeneralClickAction:

      public static ViewAction customClick() {
          return actionWithAssertions(
              new CustomGeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER));
      }
    

    But I'd rather fix the layout of the activity if possible to avoid creation of workaround for button visibility.

提交回复
热议问题