Define Selenium HTML elements as Java classes, similar to Selenium's @FindBy
annotation.
Also contains a ton of other predefined utility, for example:
- Automatically scrolling elements that perform operations into the view
- Safe click: When an element is detected as stale a JavaScript click is executed instead
- Option to globally wait until the page finished loading
- Waiting for some time until the element is present (
waitUntil
)
Overall this should result in:
- Less flaky tests
- Abstraction of elements in an object oriented way
- Define the elements you want to access
@FindBySelector(tagName = "body") abstract class BodyElement implements ImprovedWebElement { public MyElement myElement() { return waitForFirst(MyElement.class); } } @FindBySelector(id = "abc") abstract class MyElement implements ImprovedWebElement { }
- Utilize the predefined methods and classes to get/access the elements in a test
class MyWebDriverTest implements CanFindElements { WebDriver webDriver; @BeforeEach void beforeEach() { webDriver = createWebDriver(); CustomizableRemoteWebElementInstaller.install( webDriver, () -> new ImprovedRemoteWebElement( "return document.readyState == 'complete';") ); } @Test void test() { MyElement myElement = waitForFirst(BodyElement.class).myElement(); assertEquals("Hello world", myElement.getText()); // Or alternatively ElementInstantiatorInstance.instance().find(webDriver, BodyElement.class); } @AfterEach void afterEach() { // Stop webDriver here... webDriver = null; } @Override public WebDriver getWebDriver() { return webDriver; } }
You can also checkout the integrated tests to see this in action.
Installation guide for the latest release
If you need support as soon as possible and you can't wait for any pull request, feel free to use our support.
See the contributing guide for detailed instructions on how to get started with our project.
View the license of the current project or the summary including all dependencies
Disclaimer: This is not an official Testcontainers/Selenium product and not associated