Reputation: 193
is there any way to count the all available products in a e-commerce web site?
below is the html.
Cargo PantsUpvotes: 0
Views: 2549
Reputation: 693
Basically
List<WebElement> list = driver.findElements(By.id(repeating_element_ID));
int itemsCount = list.size();
where findElements
is right function for resolve this issue, because it returns list of items located by By-locator (id, xpath, name, ...). Then you can count elements by function size() on given list.
Upvotes: 1
Reputation: 11
I am not sure about what you are looking for, but in selenium there is a method to find elements in the browser:
List<WebElement> wel = null;
String newElement = (element_to_locate);
wel = this.getDriver().findElements(By.id(newElement));
Upvotes: 1