ListView中有這樣的(footer.xml)頁腳:咖啡:點擊按鈕動作ListView中頁腳
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btn_cancel"
style="@style/MyApp.Form.Component.Button"
android:text="@string/action_cancel"/>
<Button
android:id="@+id/btn_confirm"
style="@style/MyApp.Form.Component.Button"
android:text="@string/action_next"/>
</RelativeLayout>
記錄(Android Studio中通過「記錄特濃測試」)劇本當我收到以下代碼點擊按鈕「下一步」:
private void clickNext() {
ViewInteraction appCompatButton2 = onView(
allOf(withId(R.id.btn_confirm), withText("Next"),
withParent(childAtPosition(
withId(R.id.lv_products), 5))));
appCompatButton2.perform(click());
}
它的工作不錯,但...當試驗在低分辨率設備拼命地跑,我得到錯誤:
android.support.test.espresso.PerformException: Error performing 'single click' on view '(with id: com.comarch.msc.emulator:id/btn_confirm and with text: is "Next" and has parent matching: Child at position 5 in parent with id: com.comarch.msc.emulator:id/lv_products)'. (...) Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints: at least 90 percent of the view's area is displayed to the user.
如何自定義較低分辨率的測試?
可能的重複[點擊不完全可見imageButton with Espresso](http://stackoverflow.com/questions/28834579/click-on-not-fully-visible-imagebutton-with-espresso) –