Hi currently I am trying to implement a test case where I have to get the count of number of elements from a non scrollable reclyeview.
I tried to get the recycleview and add it into a list but it always showing only one item. I am using xpath. But I have the id also.
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;
}
I want the correct result. The recycleview holds 3 items initially and after clicking more button it will show 7 items.