I need click by Espresso testing in x, y.
I have view:
<view xmlns:android="http://ift.tt/nIICcg" 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>
So, in panel view: in top drawing date, under strings: text1 and text2 on one line, under some content, under - button. I draw text1 and text2 on canvas. I need click on text1 and text2 by Espresso. But, if I write: onView(withText(String.valueOf(R.string.text1))).perform(click());
- I have android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with text: is "2131492993"
, So, I want click in coordinate x,y:
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);
}
}
But, I do not know - which must be are x,y? How can to get x,y for test1 and x,y for test2?
Aucun commentaire:
Enregistrer un commentaire