Issue
I need to check if located link contains <span class="extra-light">
with a given text.
The way I locate the link:
ExpectedConditions.elementToBeClickable(By.xpath("//a[@so-extra=\"x12fog\"]"))
How to make it?
Solution
You can use findElements
method with XPath locator defining the desired element as following:
if(driver.findElements(By.xpath("//a[@so-extra='x12fog']//span[@class='extra-light' and contains(.,'stackoverflow')]")).size()>0){
System.out.println("Element found");
}
findElements
method return a list of found matching elements. So, if there is such element the list will be non-empty (size>0), otherwise the returned list will be empty.
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.