Released Selenide 6.11.0

Released Selenide 6.11.0

Results of 2022
03.01.23


Happy New Year, dear friends!

Santa Claus brought us a new release Selenide 6.11.0.

Added methods to copy and paste text

We added two methods:

  • Selenide.copy() for copying currently selected text to clipboard, and
  • $.paste() to paste clipboard content into input field.
open("https://best-propaganda-quotes.ru");
$("#solovjov").doubleClick(); // select the quote text
Selenide.copy();
$("[name=q]").paste();
$("[name=q]").shouldHave(text("Life is highly overrated"));

Known restrictions: these methods need a graphics environment. So they would not work on server linux. But simple running xvfb should help.

See issue 1817.
Thanks to Evgenii Plugatar for PR 2027.


Fixed method Selenide.download(url)

…in case if url contains login/password (the resource is protected by BasicAuth).

For example, this code worked few weeks ago, but stopped working after upgrading Apache Http client (internally used by Selenide):

File f = Selenide.download("https://admin:tiger@the-internet.herokuapp.com/basic_auth");

In the latest update, Apache Http client enforced URL validation, and this part with login/password is not allowed anymore (it’s kinda unsafe deprecated way of passing credentials).

Now Selenide removes credentials from url and sends them with http header Authorization.

See issue 2037 and PR 2102.


Now Selenide allows downloading large files via proxy

If you use PROXY method for downloading files, you might know that file size could not exceed 64 megabytes.
Initially, it seemed a reasonable limit: why should anyone need to load a test bench by downloading giant files? (even 64 mb was quite big: BrowserUpProxy by default sets limit to 2 megabytes; we increased it to 64 in Selenide)

But it turned out that sometimes people want to test downloading large files. After a discussion, we decided to simply remove this limit. You decide if you want to load your test environment.

File favoriteMovie = $("#topMovie").download();
assertThat(favoriteMovie)
  .hasName("BadSanta.avi")
  .as("2 GB").hasSize(2147483648L);

P.S. Be aware that proxy might not quickly download files that are too large. And BrowserUpProxy still has built-in technical restriction of 2 gigabytes (because of Integer type used for file size limit).

But at least now you can download, say, 200 megabyte files.

See issue 2082 and PR 2098.


Now you can handle unexpected alerts

By default, Selenide ignores unexpected alerts in browser. (More specifically, Selenide runs webdriver with option capabilities.setCapability(UNHANDLED_PROMPT_BEHAVIOUR, ACCEPT)).

On the one hand, this is convenient so that tests do not break due to sudden pop-up ads and other useless messages. On the other hand, sometimes these alerts can contain useful information - in particular, a valuable error message.

If this is your case, now you can override this option:

import static org.openqa.selenium.remote.CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR;
import static org.openqa.selenium.UnexpectedAlertBehaviour.ACCEPT_AND_NOTIFY;

Configuration.browserCapabilities.setCapability(UNHANDLED_PROMPT_BEHAVIOUR, ACCEPT_AND_NOTIFY);

Then you will get an exception saying what message that alert contained:

UnhandledAlertException: unexpected alert open: {Alert text : Oops} // chrome
UnhandledAlertException: Accepted user prompt dialog: Oops: // firefox
UnhandledAlertException: unexpected alert open: {Alert text : Oops}  // edge
UnhandledAlertException: : Oops // safari

See issue 2054 and PR 2095.


Fixed permissions for screenshot file

When your test fails, Selenide automatically takes a snapshot of current page, thus creating two files: : *.png and *.html. It turned out that these files had different permissions:

-rw------- 1 root root 300295 Dec 19 10:24 1671441847908.0.png
-rw-r--r-- 1 root root 185070 Dec 19 10:24 1671441847908.0.html

And it caused difficulties for some advanced devops how wanted to run different step of build pipeline by different users. Whatever devops amuses… :)

Now both files have the same permissions: -rw-r--r--.

See issue 2081 and PR 2084.


Support @As annotation for fields without @FindBy

In Selenide, you can give readable names (aka “aliases”) for page object fields with method as:

class LoginPage {
  SelenideElement loginButton = $(By.xpath("/long/ugly/xpath[3]")).as("Login button");
}

But there was an idea that it would be convenient to put the name at the beginning of the line. Otherwise, it would be visually lost on the right of the long selector.

Now you can give alias with annotation @As:

class LoginPage {
  @As("Login button")
  SelenideElement loginButton = $(By.xpath("/long/ugly/xpath[3]"));
}

But of course, the annotation will work only if you initialize the page object with method Selenide.page() or Selenide.open().

See issue 2087 and PR 2088.


Added methods to get last saved page source

It’s rarely needed, so don’t bother. Essentially, we added few methods to class ScreenShotLaboratory: threadScreenshots(), contextScreenshots(), lastThreadScreenshot(), lastContextScreenshot().

Thanks to Arman Ayvazyan for PR 2065.


Now you can add page URL to error message

Sometimes it might be useful, sometimes harmful. After a discussion, we decided to make this feature optional (in a form of a plugin).

Let it stay in experimental status for now. We will probably play with error message formats in the future.

See issue 980 and PR 2097.


Year summary

Let’s sum up year 2022? During this year, Selenide was mentioned in several ratings:

and finally,

Selenide monthly downloads statistics grew by half:

from 302 thousands in January
to 469 thousands in November.

And still

It’s been a terrible year.

I hope that in the coming year the war will end, the guilty will be punished, the citizens of the oppressed countries will finally overthrow their tyrants.

And the beautiful free country of Ukraine will be rebuilt and will bloom more than ever.

And after a year, we will see you in Kyiv at the wonderful SeleniumCamp conference.

Glory to the heroes!


Andrei Solntsev

selenide.org

03.01.23