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>
При записи сценария (через «Record Эспрессо Test» в 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.
Как настроить тест для более низких разрешений?
Возможный дубликат [Нажмите на не полностью видимое изображениеБутон с эспрессо] (http://stackoverflow.com/questions/28834579/click-on-not-fully-visible-imagebutton-with-espresso) –