Helper can find an element through all frames that represent on page
Dependency: Maven
<dependency>
<groupId>com.github.nick318</groupId>
<artifactId>findelement</artifactId>
<version>2.0</version>
</dependency>
Gradle
implementation 'com.github.nick318:findelement:2.0'
Examples:
//setup once
SearchByFramesFactory searchFactory = new SearchByFramesFactory(driver);
//use in different places
SearchByFrames searchInFrame = searchFactory.search(locator);
Optional<WebElement> elem = searchInFrame.getElem();
elem.ifPresent(WebElement::click);
SearchByFrames searchInFrame = searchFactory.search(() -> driver.findElement(By.tagName("body")));
Optional<WebElement> elem = searchInFrame.getElem();
This library can be used with Selenide
. All you need to do is to write a wrapper. Look for details in SelenideExamples.java
As you may noticed you can put a Supplier of WebElement as a constructor parameter, it will be invoked during search in frames.
All synchronization logic should not be placed here, it is responsibility of user.
More examples you can find in tests directory.