Released Selenide 6.16.0

Released Selenide 6.16.0

Speed up collections!
02.07.23

Good night!

I have an offer for you that you shouldn’t refuse.

Upgrade to Selenide 6.16.0!

Speed up collection checks

Here is the coolness!

One of basic Selenide features is collection checks. With just one line you can check a bunch of elements:

$$("option").shouldHave(texts("Gandalf", "Gendalf", "Gondalf"))

But such a check can take a significant time in case of big collections.

For example, if a page has 1000 <option> elements, that check takes ~3 seconds on my machine.
The slowness is due to the fact that Selenide fetches the text of each element separately. 1000 webdriver calls, even very fast ones, takes its time.

It’s time to speed up those checks!

Now Selenide fetches texts of all 1000 elements with a single webdriver call using JavaScript.

Now that check takes 200ms instead of 3 seconds.
It became 15 times faster!
That’s crazy.

P.S. For Appium and other webdriver not supporting JS, Selenide will fall back to the old implementation (fetches texts one-by-one). At least it’s not worse than before.

See PR 2362.


Improved error messages in collection checks

During the previous refactoring, we improved error message for collections. Now Selenide provides a more detailed error of which element didn’t meet the conditions:

For example, this check:

$$(".number").shouldHave(exactTexts("On", "Tw", "Thre"))

Reported just a simple "Texts mismatch" message:

Texts mismatch
Actual: [One, Two, Three]
Expected: [On, Tw, Thre]

And now it specifies what exactly didn’t match:

Text #0 mismatch (expected: "On", actual: "One")
Actual: [One, Two, Three]
Expected: [On, Tw, Thre]

See PR 2362.


New date checks date(...) and datetime(...)

import static com.codeborne.selenide.conditions.datetime.DateConditionOptions.*;

LocalDate birthday = LocalDate.of(2022, 10, 11);
$("#birthdate").shouldHave(date(birthday));
$("#birthdate").shouldHave(date(birthday, "yyyy-MM-dd"));
$("#birthdate").shouldHave(dateBetween(parse("2020-01-01"), parse("2023-12-31")));
$("#birthdate").shouldHave(dateFormat("yyyy-MM-dd"));

See issue 2268. Thanks to Maksim @Au6ojlut for PR 2281.


New methods for setting time

Selenide had a method for selecting a date (withDate):

$("#birthdate").setValue(withDate(LocalDate.of(...)));
// for <input type="date">

Now we have similar methods for selecting date and time (withDateTime):

$("#birthdate").setValue(withDateTime(LocalDateTime.of(...)));
// for <input type="datetime-local">

or only time (withTime):

$("#openFrom").setValue(withTime(LocalTime.of(7, 12)));
$("#closeFrom").setValue(withTime(LocalTime.of(17, 59, 58)));
// for <input type="time">

See PR 2357.


Full stacktrace in soft asserts

In Selenide, you can enable soft asserts mode. Then Selenide will collect several failures during a test, and throw an exception in the end. This exception will include all collected assertion errors.

The problem is that Selenide didn’t show full stacktraces, so you couldn’t see the “Caused by:” part. Now it will be shown.
Be prepared for the lengthy stack traces :)

See issue 2350 and PR 2354.


Improved BasicAuth in Chromium browsers

Selenide has methods for BasicAuth authentication:

open("/basic-auth/hello", "my.test.com", "scott", "pwd123");

Until now, we had two BasicAuth implementations.

  1. If proxy is enabled: Selenide adds an Authorization header to every http request (Basic YWRtaW460JrQsNC30LrQvtCy0LAg0LTRltCx0YDQvtCy0LA=).
  2. If proxy is disabled: Selenide adds login+password to URL (https://scott:pwd123@localhost:42220/basic-auth/hello).

Now we have a third implementation. If webdriver implements interface org.openqa.selenium.HasAuthentication, then Selenide adds login+password via this interface. Basically it means Chromium based browsers (Chrome, Chromium, Edge).

See issue 2336 and PR 2358.


Multiple domains in BasicAuth

Until now, you could set only one domain for BasicAuth:

open("/basic-auth/hello", "my.test.com", "scott", "pwd123");

It doesn’t help if AUT uses multiple domains. For example, if AUT at address “https://my.test.com” opens a frame with address “https://api.test.com” or, say, “https://api.test.com”. You can set an empty domain, but it’s not always safe.

Now you can set multiple domains separated by comma or “|”:

open("/basic-auth/hello", "my.test.com|auth.test.com|api.test.com", 
          "scott", "pwd123");

See PR 2358.

P.S. Of course, the domain name is not used when Selenide adds the login+password just to the URL.


Fixed $.doubleClick() in Appium

In a previous release we broke, and now we’ve fixed the double click in mobile phones:

$(AppiumBy.xpath(".//android.widget.CheckBox")).doubleClick();

See issue 2346 and PR 2347.


Take screenshot earlier

Usually Selenide takes a screenshot after a test failure.
BUT If you close the browser in @AfterEach method, Selenide could not take the screenshot anymore:

@AfterEach
void tearDown() {
  Selenide.closeWebDriver();
}

Now Selenide will take the screenshot earlier - BEFORE all @AfterEach methods.

See issue 2352 and PR 2356.


Updated dependencies

  • 2319 use latest version of geckodriver for FF 102+
  • 2328 bump Selenium from 4.9.1 to 4.10.0
  • 2324 Bump io.appium:java-client from 8.5.0 to 8.5.1
  • 2349 Bump Netty from 4.1.93.Final to 4.1.94.Final
  • bump WebDriverManager from 5.3.3 to 5.4.0


News


Andrei Solntsev

selenide.org

02.07.23