Reputation: 55
Verify when you go to product listing page i.e. Clothing etc. -> After 72 items, “View More” should not automatically load more, but need to be clicked button at bottom which should load more items if there are more than 12 items in this page. Also when i filter results how do i verify number of products returned in the page ?
Upvotes: 0
Views: 1051
Reputation: 50
You could get all the products currently on the page, store in a list, then use the list size to get the number of products on the page. You can then do any assertions or further actions after that.
List<WebElement> products = driver.findElements(By.cssSelector("product-item-wrapper"));
int numberOfProducts = products.size();
It also looks to me on that page that the Load More button has a data-pagination attribute that holds info about the total number of results and pages etc. So you could extract that information to use in comparisons and tests
WebElement btnLoadMore = driver.findElement(By.cssSelector("a.load-more"));
String pagingData = btnLoadMore.getAttribute("data-pagination");
Upvotes: 1