Released Selenide 5.25.0

Released Selenide 5.25.0

We will be 10 soon!
28.09.21

Good evening!

We released Selenide 5.25.0.

I strongly recommend you to upgrade,
because there are even more changes coming with next releases, including the full release of Selenium 4.
If you don’t upgrade now, it will be much more difficult to clear the rubble later!

This is quite a big release with a bunch of changes, so grab some popcorn and make some tea. Let’s go!


Support for Selenium Webdriver 4.0.0 RC1

We released two builds of Selenide 5.25.0: regular and hipster one.
You can pick:

either com.codeborne:selenide:5.25.0 (with Selenium 3.x),
or com.codeborne:selenide:5.25.0-selenium-4.0.0-rc-1 (with Selenium 4.0.0 RC1).


We added support for OpenTest4j

If you haven’t heard yet, OpenTest4j is a small library for assertion errors created by JUnit 5 team. The idea is that:

  • all testing frameworks should throw these errors, and
  • all IDEs should support them.

Yet another standard, like webdriver. :) All major players like JUnit, TestNG, AssertJ, IDEA and Eclipse already supported opentest4j, and now does Selenide too.

What will change for you personally:
When your UI fails (well, almost always), IDEA will show a nice link <Click to see difference> below. By clicking it you can view a nice DIFF in a separate IDEA dialog. Very convenient for debugging.

See issue 969 and PR 1545.

NB! If you use directly some of Selenide assertion errors (inherit or throw), you will need to update your code a bit.
We slightly change signature of their constructors:

  • flipped “expected” and “actual” arguments
  • removed unneeded “driver” argument from most constructors



Now we show stacktrace below every error in soft asserts

Until now, Selenide soft asserts showed only one stack trace in the end of all errors. It allows to keep the total error message (relatively) short.
But in practice it’s convenient to see a separate stacktrace for every error. It allows to quickly click the needed line and get to the right place in the code.

Now you will see separate under every error. I personally don’t like that the error message has become much longer, but usually there shouldn’t be too many of errors, right? ;)

See issue 1543 and PR 1545


We added method $.shadowRoot()

Until now, you could only search elements inside of shadow root, and now you can get the shadow root itself.
Though, there is still little benefit from this because search within this element is not supported (by browsers or web drivers, I am not sure).

See issue 1515 and PR 1517.


We added method $.ancestor()

It’s an alias for existing method $.closest(). The name closest was originally from JQuery (which is old!), while ancestor should be more clear because it’s a standard XPath term.

See issue 1556.
Thanks to Oleg Berezhnoy for PR 1567.


We enriched methods $.closest() and $.ancestor()

Until now, this method could only search element by tag or class name:

  • $.ancestor("table").shouldBe(visible)
  • $.ancestor(".form").shouldBe(visible)

Now it can search by attributes:

  • $.ancestor("[argument-name]");
  • $.ancestor("[argument-name=argument-value]");

Thanks to Vitali Plagov for PR 1554


We fixed method $.screenshot() on Mac

For a long time, Selenide has method $.screenshot() to take screenshot of some element (instead of a full screen).
We found that this method worked incorrectly on MacBooks because of Retina display.

Now we remove the incorrect custom code from Selenide and started using a standard webdriver method that was created meanwhile. We checked it works in at least Chrome, Firefox and Edge.

See issue 1571 and PR 1576.


Now Selenide reports an exact text at the moment of test failure

Wow, what old issues we sometimes fix! This ticket was registered already on September 6, 2015!

In general, the story is like this.

Let’s assume you have a check in test:

$.shouldHave(text("Hello"));

And a standard timeout 4 seconds. Here is one possible scenario:

  1. during 4 seconds, Selenide checks the element text, but it’s wrong all the time (say, “Goodbye”).
  2. timeout expires,
  3. selenide decides to throw an assertion error,
  4. composes an error message, including actual element text.
  5. at this moment the element text changes. Say, to “Hello”.

It happens very rarely, but when it happens, it may confuse a lot.
You are seeing an error message and feel totally confused:

Text didn’t match. Expected text: “Hello”, actual text: “Hello”.

Now Selenide remembers exactly the text at the moment of last check and appends it to the error message.

P.S. In next releases, we are going to improve this mechanism even more. We will show the history of element texts during those unfortunate 4 seconds. It may help debugging some tricky cases with flaky tests etc.

See issue 217 and PR 1566.
Thanks to Pavel Fokin for PR 1313.


We now forbid an empty argument in method $.matchText("")

There is a method for checking element text with a regular expression:

$("#child_div1").should(matchText("Tallin{1,2}")));

We found that it was possible to occasionally pass an empty string to matchText which might cause false-positive tests.
Now you will see an exception when trying to execute $.should(matchText(""))):

java.lang.IllegalArgumentException: Argument must not be null or empty string

See PR 1566


We added check webdriver().shouldHave(title(...))

As usually, you can use it with default or custom timeout:

webdriver().shouldHave(title("Login page"));
webdriver().shouldHave(title("Login page"), ofMillis(10));

See issue 1573.
Thanks to Ervīns Patmalnieks for PR 1579.


selenide-selenoid 1.2.0

We released selenide-selenoid:1.2.0 with upgrade to Selenide 5.25.0.


selenide-appium 1.7.0

We released selenide-appium:1.7.0 with upgrade to Selenide 5.25.0.


Selenide downloads statistics


The milestone has been passed: we exceeded 250 thousand downloads per month.


Selenide anniversary

By the way, we have come close to another significant milestone: in October, Selenide will be … 10 years old!
It’s hard to believe, but the first commit was made in the repository on October 25, 2011. Just look how ridiculous it was! :)


Andrei Solntsev

selenide.org

28.09.21