您好,我目前正在尝试实施一个测试用例,其中必须从不可滚动的relyeeview获取元素数。
我试图获取recycleview并将其添加到列表中,但始终只显示一个项目。我正在使用xpath。但是我也有身份证。
public static final String dashboard_recycleview_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.support.v7.widget.RecyclerView";
public boolean ticketPurchaseFromDashboardTest() throws InterruptedException, IOException {
boolean testPassed = false;
skipToDashboard();
TimeUnit.SECONDS.sleep(WaitingTime.oneSecond);
helper.performClick(AndroidIdentifiers.dashboard_buy_a_ticket, true);
TimeUnit.SECONDS.sleep(WaitingTime.oneSecond);
helper.findListViewContent(AndroidIdentifiers.dashboard_recycleview_xpath, false);
//
return testPassed;
//Check if an element of the screen that should appear in the end of the test is there
}
public boolean findListViewContent(String elementId, boolean xPath) {
//driver.findElements(by.xpath(elementId));
//driver.findElements(By.xpath(elementId)).
List weekObjectList = driver.findElements(By.xpath(elementId));
System.out.println(weekObjectList.size());
return true;
}
我想要正确的结果。 recycleview最初包含3个项目,单击更多按钮后将显示7个项目。
布局:
元素检查屏幕: