InBrowserFinder { public static WebElement findPageWithNumberOfOccurrences(WebDriver driver, final Path el, int numberOfOccurrences) { return findPageWithNumberOfOccurrences(driver, el, numberOfOccurrences, RelationOperator.exactly); }  static List<WebElement> findAll(WebDriver driver, final Path el); static WebElement findPageWithNumberOfOccurrences(WebDriver driver, final Path el, int numberOfOccurrences); static WebElement findPageWithNumberOfOccurrences(WebDriver driver, final Path el, int numberOfOccurrences, RelationOperator relationOperator);  }
@Test public void findNTimes() { when(driverMock.findElement(By.xpath("/html[count( assertThat(InBrowserFinder.findPageWithNumberOfOccurrences(driverMock, BasicPath.div, 5), is(equalTo(webElement2))); }
@Test public void findNTimesUnderlying() { when(webElement.findElement(By.xpath(".[count( Path path = BasicPath.builder().withUnderlying(webElement).withXpath("div").build(); assertThat(InBrowserFinder.findPageWithNumberOfOccurrences(driverMock, path, 5), is(webElement2)); }