Released Selenide 5.23.0

We will be 10 soon!

Blog

Released Selenide 5.23.0

New generation checks

Good summer day!

We released Selenide 5.23.0 on July, 16.

It introduces a fundamentally new feature in Selenide:

The new generation checks

Now Selenide has checks not only for web elements, but for some other elements too. You can apply those checks with built-in waitings, readable error messages, reports etc. Everything you like.

See issue 1442. Thanks to Dmitriy Budim for launching this whole epic in PR 1478.


Let’s look at these checks.

Checks for URL

Until now, there were 2 methods in Selenide to get an URL of a current page or frame (in most cases it’s the same value).

  String url1 = WebDriverRunner.url();
  String url2 = WebDriverRunner.currentFrameUrl();

Though, it was not clear how to check them or wait for a right url.

Now we have such checks:

import static com.codeborne.selenide.Selenide.webdriver;
import static com.codeborne.selenide.WebDriverConditions.*;

webdriver().shouldHave(url("https://auth.google.com"));
webdriver().shouldHave(url("https://mastercard.ee"), Duration.ofSeconds(42));
webdriver().shouldNotHave(url("http://yandex.ru");
webdriver().shouldNotHave(urlStartingWith("ftp://"));
webdriver().shouldHave(currentFrameUrl(baseUrl + "/login.html"));
webdriver().shouldHave(currentFrameUrlStartingWith(baseUrl + "/logout.html"));

Every of these checks:

  1. waits up to 4 seconds (by default) if needed
  2. appears in a report (text report or Allure)
  3. takes a screenshot and throws a readable ConditionNotMetException if the url is not as expected after 4 seconds.

In the best traditions of selenide, you can

  • override the default timeout (4 seconds) to any other number, e.g. Configuration.timeout = 8000;
  • set a custom timeout for every check (as a second parameter like Duration.ofSeconds(42))
  • create custom checks (see example)

Checks for clipboard

Starting from version 5.20.0, Selenide has a method for accessing the clipboard:

Clipboard clipboard = Selenide.clipboard();

But you could only get or set text to the clipboard:

String foo = clipboard().getText();
clipboard().setText("bar");

Now you can also check the clipboard content. Again, with automated screenshots, reports, etc.

clipboard().shouldHave(content("Hello fast World"));
clipboard().shouldHave(content("Hello slow World"), Duration.ofMillis(1500));

See PR 1507

Checks for localStorage

Starting from version 5.15.0, Selenide has method localStorage() which return JavaScript object LocalStorage.
But it had only methods getItem and setItem. Again, it was not clear how to check them or wait for an item in the local storage.

Now it’s clear:

  • localStorage().shouldHave(item("cat”));
  • localStorage().shouldHave(itemWithValue("mouse", "Jerry”));

By the way, we also added method localStorage.getItems() returning all the content of localStorage as a map.

See example of custom condition in Selenide tests.

See PR 1502

Checks for sessionStorage

The same as for localStorage - we added methods

  • sessionStorage().shouldHave(item("cat”));
  • sessionStorage().shouldHave(itemWithValue("mouse", "Jerry”));
  • Map<String, String> items = sessionStorage.getItems();

See PR 1502


A small refactoring

We made classes StaticConfig and StaticDriver non-public.
It seems they shouldn’t be needed outside of Selenide. Do you occasionally use them in your project? Contact us if you are sure you need them.

And a small bugfix:

Now method Selenide.screenshot("filename") (again) takes a screenshot even if setting Configuration.screenshots is false.

Let me clarify.

  1. You can set Configuration.screenshots to false if you need to disable automated screenshots in case of test failures (actually, I don’t really see any reasons to do that).
  2. You can use method Selenide.screenshot("filename") to take a screenshot at any moment you wish. Independently if the test status (I also don’t really see any reasons to do that:))

The point is that method #2 works independently of setting #1. Now you can disable the automated screenshots and only take screenshots explicitly where needed (though, I still don’t see any reasons why it should be a good idea).

See issue 1477 and PR 1506


selenide-selenoid 1.1.4

We released selenide-selenoid:1.1.4 with upgrade to Selenide 5.23.0


selenide-appium 1.6.7

We released selenide-appium:1.6.7 with upgrade to Selenide 5.23.0


New links


Statistics

We crossed the line 232+ thousands of downloads per month!

Have a carefree summer!


Andrei Solntsev

selenide.org

The project is maintained by