Good evening!
We released Selenide 7.6.0 with something tasty and interesting.
Yo-yo, rush to update!
Videos are a serious thing. If there are videos, then they reflect something.
What’s new:
because
for webdriver conditions$.scrollIntoCenter()
inNewBrowser
with custom configurationSelenide.screenshot(filename)
behaviourFinally!
We all encounter unstable tests. Blinking tests. Flaky tests.
If this topic is new to you, I envy you. You are in for a fascinating dive into
Flaky Tests.
When investigating flaky tests, videos may be very helpful. And now Selenide can save videos from tests out of the box.
Few years ago, we used to use the VideoRecorder library by Sergey Pirogov a lot. But now Sergey is assembling drones for the Ukrainian Armed Forces and is not working on open source for the time being. Such are the times. :(
How to start recording videos?
It’s easy.
selenide:7.6.0
by selenide-video-recorder:7.6.0
org.selenide.videorecorder.junit5.VideoRecorderExtension
to your tests (in case of JUnit5)org.selenide.videorecorder.testng.VideoRecorderListener
to your tests (in case, God forgive me, TestNG)@Video
to your unstable tests (there aren’t many of them, are there?)Now Selenide starts recording videos for all annotated tests.
BUT
the videos will be saved only when a test fails. A link to the video will be added to the error message - just as link to a screenshot.
Element should have text "Oreshnik"
Actual value: text="Kokoshnik"
Screenshot: file:/.../build/reports/tests/1732761758509.0.png
Page source: file:/.../build/reports/tests/1732761758509.0.html
Video: file:/.../build/reports/tests/1732761754743.0.webm
How it works?
Before every annotated test, Selenide starts 2 threads:
org.bytedeco:javacv
)After the test, the video is either deleted or saved to a file, and attached to the error message.
P.S. The abovementioned behaviour and some parameters can be configured in file selenide.properties
, see VideoConfiguration.
NB! Keep in mind that video recording consumes resources and slows down your computer. Use sparingly.
See issue 2145. Thanks Sergey Brit for PR 2768,
Also see PR 2890 with annotations and configuration.
because
for webdriver conditionsNow you can write not just:
webdriver().shouldHave(numberOfWindows(2)));
webdriver().shouldHave(url("https://dictionary.cambridge.org")));
but with an explanation:
webdriver().shouldHave(
numberOfWindows(2).because("The login page should open in a new window"));
webdriver().shouldHave(
url("https://dictionary.cambridge.org/").because("WTF is Oreshnik?"));
Thanks to Daniil Moiseev for PR 2853.
$.scrollIntoCenter()
It’s essentially the same as $.scrollIntoView("{block: 'center'}")
but shorter.
Because in most cases, when we scroll, that’s exactly what we want.
$("#logout")
.scrollIntoCenter()
.shouldHave(text("A murky button somewhere at the bottom of the screen"))
.click();
See PR 2842.
When we search a web element by text, or verify the element’s text, we usually need to ignore spaces.
According to the HTML specification, several consecutive spaces are considered as one space.
Until now, Selenide treated several whitespace characters in this way (<space>
, <tab>
,
, <newline>
). But it turned out that there are many more different distorted spaces (so-called “En Space”, “Em Space”, “Three-Per-Em Space” etc.). Now we can ignore them all. :)
For example, for a web page like this:
<div id="hero">
Ahoo         ⁠  
      Daryae
</div>
The following test will work:
$("#hero").shouldHave(text("Ahoo Daryae"));
$(byText("Ahoo Daryae")).ancestor().shouldHave(
text("Say Her Name"));
Thanks to Daniil Moiseev for PR 2858.
See also PR 2884.
inNewBrowser
with custom configurationThis is rarely used, so don’t bother. But I have to mention it.
First of all, we added method inNewBrowser
with config
parameter for opening a new browser with custom configuration:
inNewBrowser(Config config, Runnable lambda)
Second, we fixed the existing method inNewBrowser(Runnable lambda)
which didn’t restore the previous config if the browser was closed inside it.
See issue 2859 and PR 2902.
Fixed bug in selenide-appium
when a test tried to create page object for website, not mobile app. And website was not opened yet.
Thanks to Petro Ovcharenko for PR 2879.
We reviewed Selenide logs and converted some “info” logs into “debug”.
In other words, there should be less spam in the logs now.
If you need to debug some complex problem, turn on the “debug” level. ;)
See PR 2892.
Selenide.screenshot(filename)
behaviourIn javadoc of this method, it was mentioned that it creates two files - “.html” and “.png”. But in reality it created only “*.png”. Now the behaviour of this method matches the description in javadoc.
See issue 2896 and PR 2901.
Many Selenide methods were annotated with @Nullable
, @Nonnull
, @CheckReturnValue
, @ParametersAreNonnullByDefault
.
This is useful to help you avoid some typical bugs. Thanks to these annotations, IDE can highlight this code with a warning:
$("h1"); // Ooops, somebody forgot a check: .shouldBe(visible)
Until now, we took these annotations from library “JSR 305” (the annotations were imported from package javax.annotation
).
But this library is not supported anymore.And recently a new library JSpecify was released to replace it. Now Selenide migrated to JSpecify. The annotations are now imported from packages org.jspecify.annotations
and com.google.errorprone.annotations
.
See PR 2889.
If you created a subclass from Click
, SetValue
or some other Selenide built-in command, then we accidentally broke your backwards compatibility. Sorry. :)
Now instead of method
public SelenideElement execute(SelenideElement proxy, WebElementSource locator, Object [] args) { ... }
you need to implement/override method
protected void execute(WebElementSource locator, Object @Nullable [] args) { ... }
But it’s shorter and simpler this way, right?
But in general, if your project compiles, then don’t worry, it doesn’t concern you. :)
See issue 2906 and PR 2889.
Monthly Selenide downloads hit the new record: 1.3 millions in October!
24.11.24