Perhaps this is what you want:
public void getIframe(final WebDriver driver, final String id) {
final List<WebElement> iframes = driver.findElements(By.tagName("iframe"));
for (WebElement iframe : iframes) {
if (iframe.getAttribute("id").equals(id)) {
}
}
}
However, it is important to remember that if there are too many such objects on your page, the code may become a little slower, but I'm talking about more than 100+ in my tests using this solution.
source
share