Released 5.17.0

an anniversary release

Blog

Released 5.17.0

Ho-ho-ho, Page Objects!

Good night!

I am passionate about Catholic Christmas. Because it was on Christmas that the terrorists took over the Nakatomi plaza and Bruce killed Hans Gruber. And then he blew up the plane with a lighter.

So catch the Christmas release Selenide 5.17.0.


Added method $.as(“name”)

We added method as, so that you can give elements readable names.

To feel the difference, let’s compare the following two lines in test:

  $(By.xpath("/long/ugly/xpath[1][2][3]")).shouldNot(exist);
  $(By.xpath("/long/ugly/xpath[1][2][3]")).as("Login button").shouldNot(exist);

The test result looks like this:

  +---------------------------------------+--------------------+----------+----------+
  |Element                                |Subject             |Status    |ms.       |
  +---------------------------------------+--------------------+----------+----------+
  |By.xpath: /long/ugly/xpath[1][2][3]    |should not(exist)   |PASS      |13        |
  |Login button                           |should not(exist)   |PASS      |38        |
  +---------------------------------------+--------------------+----------+----------+

In the last line, we see a readable name “Login button” instead of long unreadable xpath.

NB! Don’t rush with using this feature. I personally take it as a “last sort hack”.
It’s always better to see the real locator instead of a name which always may happen to be:

  • Deceiving
  • Deprecated
  • Misleading

It’s always better to invest your time in readable locator, method names, well-organized tests etc. This is where the real power lies.

See issue 1200 and PR 1353.


Added bunch of default options to headless chrome

We added the same default options to headless chrome as in Puppeteer.
We assume that Puppeteer guys are smart, so we do like them. :)

Thanks to Aliaksandr Rasolka for PR 1329.


Fixed ByShadowCss.findElements

It returned only subset of elements in a particular case: when DOM contained multiple inner shadow hosts.

Now it returns all the elements.

See issue 1346. Thanks to Daniel H. Peger for PR 1347.


Added $.should* methods with custom timeout

As you know, there are two major groups of methods in Selenide:

  1. $.shouldHave / $.shouldBe / $.should – use default timeout
  2. $.waitUntil / $.waitWhile – use given timeout

$.wait* are useful for “long” actions that last longer than the default timeout (which is 4 seconds by default).


The problem with $.wait* methods is purely grammatical: Selenide built-in conditions don’t sound correctly with verb “wait”:

  1. element should have text - sounds right
  2. element wait until text - doesn’t sound right

Now you can replace $.waitUntil(hasText("bob"), 18_000) by $.shouldHave(text("bob"), Duration.ofSeconds(18)).

See issue 1136, issue 1338 and PR 1340.


Page objects

The next block of improvements concerns the Page Objects.

As you know, in Selenide it’s possible to create page objects

  • with fields annotated with @FindBy,
  • which can be standard selenium WebElement,
  • or our SelenideElement,
  • or even reusable components ElementsContainer which can be used to compose more complex page objects.

And it all works in the best traditions of selenide: lazy loading and reloading of elements etc.


There were some issues with those @FindBy fields:

  1. lazy loading didn’t work for PO fields of type List<ElementsContainer> (see issue 282 and 482)
  2. PO fields of generic types were not supported (see issue 694)

It was hard to fix. I had to dive into (quite old) code and refactor it. I had to strain my brains and apply all my remnants of the former abstract thinking. :)

That’s why these two pull requests are my pride:


And finally, a couple of technical improvements:

  • split Selenide project to subprojects - see PR 1348
  • fixed Selenide tests that depended on OS - see issue 1344 and PR 1345, thanks to Daniel H. Peger
  • cleaned up Plugins code – thanks to Yuri Orlov for PR 1343
  • upgraded to browserup-proxy:2.1.2 and guava:30.1-jre
  • added support for chrome 88, edge 89, opera 73


Known issues:

  • file selenide-5.17.0-javadoc.jar happened to be incomplete: it doesn’t contain javadoc for some of Selenide classes. Will be fixed in 5.17.1.


Summarizing

In general, we end the year on a positive note:
performed a non-trivial refactoring and fixed several old pains.
We are entering the New Year with only one screen in github issues instead of two.

And the number of downloads of selenide has grown over the year from 102 to 167 thousand.


Happy New Year!

Andrei Solntsev

selenide.org

The project is maintained by