While trying to figure out how to locate a specific group of web elements, I came across this question and I was wondering if I can do the same action just that it would give me only the descendants elements that contain a specific attribute.
For clarification, I know that I might be able to filter it but I'm looking for a way to do it without filtering.
Furthermore, I'm using java, and as web driver I use chrome driver (and I use Selenium for that, I don't know if it's obvious or not as that's the only web controlling tool that I learned so far...)
Thanks for the answers ahead!
To find elements with attribute that contains 'attributeValue':
List<WebElement> childs = rootWebElement.findElements(By.xpath(".//*[contains(@attributeName,'attributeValue')]"));
To find elements with attribute that fully matches 'attributeValue':
List<WebElement> childs = rootWebElement.findElements(By.xpath(".//*[@attributeName='attributeValue']"));