Espresso:如何单击 AdapterView 中位置 2 的项目
Espresso : How to click on an item at position 2 in AdapterView
我是 Espresso 和移动测试的新手,我正面临挑战。我必须在 App 中搜索联系人,然后单击显示在第二个位置的联系人。
我检查了很多类似的帖子,但其中 none 对我的示例有效。
搜索代码:onView(withId(R.id.textSearch)).perform(typeText("pa"));
Select 代码:onView(withText("Parth Vyas")).perform(click());
但是如果我想 select 显示在位置 2 的任何元素,我该怎么做呢?
如果你知道搜索后的位置,那么你可以试试这样:
onData(anything()).inAdapterView(YOUR_ADAPTER_VIEW_MATCHER).atPosition(2).perform(click());
我是 Espresso 和移动测试的新手,我正面临挑战。我必须在 App 中搜索联系人,然后单击显示在第二个位置的联系人。
我检查了很多类似的帖子,但其中 none 对我的示例有效。
搜索代码:onView(withId(R.id.textSearch)).perform(typeText("pa"));
Select 代码:onView(withText("Parth Vyas")).perform(click());
但是如果我想 select 显示在位置 2 的任何元素,我该怎么做呢?
如果你知道搜索后的位置,那么你可以试试这样:
onData(anything()).inAdapterView(YOUR_ADAPTER_VIEW_MATCHER).atPosition(2).perform(click());