I have a SeleniumElement that represents a couple of elements on the page, and I would like to filter it to only include ":visible" elements.
I might be able to refine the original constructor to only contain one elemnent, but I’m asking if I can do something different: given a particular element, create a new element that filters on this element’s selector.
Something like this:
public static SeleniumElement visible(SeleniumElement element) {
// Locator.filter() doesn't really exist, the next line won't compile
By locator = element.getElementLocator().filter(":visible");
return new SeleniumElement(element.getName(), locator, element.getPage());
}
visible(myButton).click();
// Calling myButton.click() fails because there are multiple elements that match
// the selector. However, only one of them is visible right now
if you want to filter the elements via their visibility then Using CSS Selector would be a good choice.
I have added both css properties Display and Visibility. Hence you can use any one property/attribute by which you can find the target element. (C# Code)
I hope this helps. All the Best 🙂