Friendly Locators in Selenium
{EDIT: Friendly locators have been renamed as Relative Locators in Selenium} Here is the first cut of Friendly locators
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//Sample driver.findElements(withTagName("p").above(lowest)); List<String> ids = elements.stream().map(e -> e.getAttribute("id")).collect(Collectors.toList()); //In Test @Test public void shouldBeAbleToCombineFilters() { driver.get(appServer.whereIs("relative_locators.html")); List<WebElement> seen = driver.findElements(withTagName("td").above(By.id("center")).toRightOf(By.id("second"))); List<String> ids = seen.stream().map(e -> e.getAttribute("id")).collect(Collectors.toList()); assertThat(ids |
All credits to the master Simon Stewart.