lundi 22 octobre 2018

Webdriver get list of children and filter it with xpath

I am getting a list of children of my root WebElement like this:

    WebElement listOfAddedBuildings = driver.getWebElement("//*[@id=\"right-list\"]/div/mat-list", 10);
    List<WebElement> child = listOfAddedBuildings.findElements(By.xpath(".//*"));

But now it returns a list of Elements including elements that I don`t need, how can I modify it to filter and return only elements that contain "h3" tag, but DOES NOT contain "mat-icon" tag, currently I am simply doing it like this, but dont feel like its best way:

if (xPath.contains("h3") && !xPath.contains("mat-icon"))

Thank you.

Aucun commentaire:

Enregistrer un commentaire