Мне нужен клик по проверке эспрессо в x, y.Как щелкнуть по необходимой координате x, y по эспрессо в тесте?
У меня есть мнение:
<view xmlns:android="http://schemas.android.com/apk/res/android" class="uk.co.senab.actionbarpulltorefresh.extras.actionbarcompat.PullToRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:id="@+id/pull_to_refresh_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/date_param"
android:textSize="@dimen/default_text_size"
android:textColor="@color/palette_light_gray"
android:layout_marginTop="25dp"
android:layout_marginLeft="28dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<example.ui.view.UnderlinedTextIndicator
android:id="@+id/tab_indicator"
android:paddingLeft="@dimen/field_padding"
android:paddingRight="@dimen/field_padding"
android:layout_below="@+id/date_param"
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_marginBottom="7dp"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="@+id/tabbed_content"
android:layout_above="@+id/btn_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tab_indicator"
android:layout_marginTop="10dp"/>
<example.ui.BigButton
android:id="@+id/btn_item"
android:text="@string/btn_convert_rates"
style="@style/BigButton"
android:layout_marginTop="10dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</view>
Таким образом, с точки зрения панели: в верхней дате рисования под струнами: text1 и text2 на одной линии, под некоторым содержанием под - кнопки. Я рисую текст1 и текст2 на холсте. Мне нужно нажать на text1 и text2 на Espresso. Но, если я пишу: onView(withText(String.valueOf(R.string.text1))).perform(click());
- У меня есть android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with text: is "2131492993"
, поэтому я хочу, нажмите на координаты х, у:
private static ViewAction clickXY(final int x, final int y) {
return new GeneralClickAction(
Tap.SINGLE,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
float[] coordinates = {screenX, screenY};
return coordinates;
}
},
Press.FINGER);
}
}
Но, я не знаю, - которые должны быть равны х, у? Как можно получить x, y для test1 и x, y для test2?