Released Selenide 5.13.0

Released Selenide 5.13.0

In the beginning was the Substring

Good morning!

Good summer!

We released Selenide 5.13.0.

Be prepared: it might break your tests (if they were not accurate).

Method $.shouldHave(text("")) now throws an exception

Probably most popular Selenide method is $.shouldHave(text("something")). But if you even use it daily, you might not realize that it checks a substring, not the whole text.

So, a check $("h1").shouldHave(text("ello")) works even for element <h1>Hello World</h1>.

A special case of this check is empty text: $("h1").shouldHave(text("")). This check is useless becase any string contains an empty substring.

If you need to check that text is empty, you can use either $("h1").shouldHave(exactText("")) or $("h1").shouldBe(empty).

We want to help you overcome this typical problem and avoid useless checks. Now Selenide will throw an exception if you pass null or empty string to method text("").

I tried Selenide 5.13.0 on my current project and found 20-30 tests that failed because of this new exception.
All of this were logical errors in tests. You see what a useful change waits for you. :)

See issue 1156.
Thanks to Roman S.A. for PR 1186.

Later we added setting FULL_TEXT, that makes Selenide check the whole string, not a substring.

Removed duplicated allure logs

You might see that Selenide may logs the same action twice in some cases. For example, when executing this:


(actually this problem is not only in Allure reports, but also in usual Selenide TextReport)

Now we removed those duplicated logs. We had to refactor some code and change some other error messages, so be prepared.

See issue 997 and PR 1193.

Improved error messages for collections

Another story where we have changed error message format in case of search failure inside a collection. I hope it should be clearer now what exactly Selenide failed to find.

See issue 967 and PR 1189.

Fixed uploading of files without <form> tag

As you probably know, Selenide allows uploading multiple files with one command:

    new File("a.txt"),
    new File("b.txt"),
    new File("c.txt")

To enable it, we once did a JS trick in Selenide.
Now it appeared that this hack required <input> to be inside of <form>. This is reasonable, but for some reason there are inputs that exist outside of <form>. Our $.uploadFile() didn’t work for them.

Now we simplified upload implementation. Now it works for any inputs and doesn’t use JS tricks.

See issue 943 and PR 1188.

Fixed downloading files with quotation marks in the name

… and other “bad” symbols.

It sounds strange, but sometimes people want to download files that have bad symbols in name (quotation marks, apostrophes etc). Linux and Mac can save such files, but Windows cannot. Selenide method $.download() failed on Windows for such files.

Now method $.download() replaces quotation marks and other “bad” symbols in file name by underscore, as all major browsers do.

See issue 1196 and PR 1199.

Configured webdriver to write its logs to a file

Until now, webdrivers started by Selenide didn’t write their logs to anywhere. You had to enable it explicitly if you needed them.

Now Selenide enables webdriver logs by default. They are written to file like build/reports/tests/webdriver.ts_pid_tid.log.
You can get full file name from Selenide logs like this:

INFO Write webdriver logs to: /andrei/build/reports/tests/webdriver.1594248139109_18125_1.log

Read these logs next time when you need to debug some weird webdriver behaviour.

See issue 1206 and PR 1207.

Added new way of downloading files: FOLDER

As you probably know, Selenide has 2 options for downloading files: HTTPGET and PROXY.
See post in our blog.

  • HTTPGET - simple and stable. But it can only download files using links like <a href>.
  • PROXY - generic and powerful. But it may cause problems if you run browser remotely because it requires access from “browser machine” to “tests machine”. It often causes troubles for Selenoid and Grid users.

Now we have a third option: FOLDER.

To use it, just add this line in the beginning of tests:

Configuration.fileDownload = FileDownloadMode.FOLDER;

It’s working mechanism is very simple:

  1. It clicks the element,
  2. Watches for new files in folder build/downloads
  3. If there are several new files, tries to guess which one if them suites better.

As always, you can find a working example in Selenide own tests.

P.S. We consider this option experimental by now because there are some nuances:

  1. It works well on local run with single browser, but
  2. During parallel run, multiple browsers might download their files into the same folder, and then Selenide might pick a wrong file.
  3. During remote run, this option doesn’t work at all. Tests are on machine A, but browser and files are on machine B.
  4. Currently only Chrome, Firefox, Edge, Opera are supported. But IE and Safari are not: they don’t allow to configure the downloads folder.

We will work on those nuances. Please share your thoughts on how can we solve them.

See issue 1212, PR 1213 and PR 1215.

UPD Later we improved method FOLDER, and now you can safely use it in your projects.

Method $.getWrappedElement() waits for the element. Again.

Probably it doesn’t affect you, but I have to mention it. Essentially, we reverted one recent change (made in Selenide 5.11).

Assuming you have the following code:

SelenideElement button = $("button");
executeJavascript("arguments[0].click()", button);

where button is shown with a delay.

Selenide always waits for this button to appear, and only then executed the JS code.
In Selenide 5.11 we did a change, so that Selenide didn’t wait for the button anymore.
It could break some tests which occasionally relied on that behaviour.
Now we restored that old behaviour: Selenide waits for the button again before executing JS code.

See issue 1191 and PR 1203.

Upgraded to BrowserUpProxy 2.1.1

Just in case

Upgrade. Try. Share you feedback.


And here is my favorite part: latest Selenide downloads statistics.
We hit the line 160 thousands per months!

and 31+ thousands of unique IPs:

Life is good!

Andrei Solntsev