Reputation: 41
I have to check a particular child tag inside the multiple parent tag (
I have code to check child tag inside the single parent class but in my case, that code is not helpful
<div class="company-cat-group"
<ul> ==$0
<li>
<i class="cultivation-icon"></i>
</li>
the parent tag(<div class="company-cat-group"
) is repeated multiple times and in every parent tag I have to check that child tag (<i class="cultivation-icon">
) is present or not
Upvotes: 2
Views: 230
Reputation: 7563
*Java
You can use List
to collect the parent elements you mean, and extract them one by one using loop
.
Then try find element in an element, selenium provided it.
Try the below code:
List<WebElement> elements = driver.findElements(By.className("company-cat-group"));
for(WebElement element: elements) {
List<WebElement> child = element.findElements(By.className("cultivation-icon"));
if(child.size()>0) {
System.out.println("present");
}
}
Upvotes: 1