android – 点击浓缩咖啡中的FloatingActionButton

尝试在espresso测试中单击FloatingActionButton.

onView(withId(R.id.actionButton)).perform(customClick())

我的方法customClick:

fun customClick(): ViewAction {
    return actionWithAssertions(
            CustomGeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER))
}

还要创建具有一些更改的类CustomGeneralClickAction:

Matcher<View> standardConstraint = isDisplayingAtLeast(60);

这个例子我从answer开始.
但有下一个错误:

android.support.test.espresso.PerformException: Error performing ‘single click’ on view ‘with id: com.fentury.android:id/actionButton’.

Caused by: android.support.test.espresso.PerformException: Error performing ‘click (after 3 attempts)’ on view ‘unknown’.

还在这里:

at com.fentury.android.acceptanceTests.utils.CustomGeneralClickAction.perform(CustomGeneralClickAction.java:79)

status = tapper.sendTap(uiController, coordinates, precision);

最佳答案 它应该是onView(withId(R.id.floating_action_button)).perform(click());

点赞