Of all the libraries I’ve used over the years, Selenide has come to occupy a top spot in my developer’s toolkit second only to that of jQuery. Selenide has played a crucial role in making Selenium (while functional) easy to use.
I’ve been using Selenide for a few months on a current project; I’ve finally got enough code coverage to where I’m able to take a few minutes and refactor the test code to be more efficient and readable. I’ve been suffering from some intermittent test failures due to timing issues with JUnit asserts, and finally found the time to address them.
Previously, I had written:
assertTrue("Element should be displayed.", $(elem).isDisplayed());
But with a few months of Selenide under my belt, I now know that it’s always better to use the SelenideElement.should() methods where possible. With should(), Selenide will by default check for a state every 100ms until 4 seconds have expired. But, Selenide does not include a check for whether an application is in fullscreen mode. By extending the existing com.codeborne.selenide.Condition class, I get:
Now I can use it within the Selenide should framework: