ページ上のいくつかの要素を表すSeleniumElementがあり、":visible"
要素のみを含むようにフィルタリングしたいと思います。
元のコンストラクターを改良して1つの要素のみを含めることができるかもしれませんが、別のことを実行できるかどうかを尋ねています。特定の要素を指定して、この要素のセレクターでフィルター処理する新しい要素を作成します。
このようなもの:
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