Changes in Selenide 2.9

Changes in Selenide 2.9

Safari support, multi-threaded TestNG run support and upgrade to Selenium 2.40.0

Good evening!

Today was released Selenide 2.9. Let me tell you about the changes in the new version.

New functionality

Added support for Safari browser

Indeed, Safari driver doesn’t seem to be stable yet. At least, some Selenide tests still fail on Safari.

Another problem with Safari is that it doesn’t support JS alerts and cannot open local files like file://c:/tmp.txt.

Please feel free to share your experience with Safari webdriver!

Added condition or

Now you can declare composite conditions like this:

    Condition completed = or("completed", started, inProgress, loading);

and use them in your tests:


Actually I am not sure it’s a good idea. I believe that test should always know exactly, in which state the element should be at any moment. But folks insisted that or condition can be useful.

Added method

Now JUnit users can declare screenshooter like this:

public class MyTest {
  public ScreenShooter photographer = failedTests().to("test-results/reports");

In most cases it’s not needed, because path for screenshots can be declared using system property: -Dselenide.reports=test-results/reports or programmatically: Configuration.reportsFolder=test-results/reports. So, the new method can only be useful if you need different paths for different tests.

Bugfixes and improvements

Method $.download() throws FileNotFoundException (if server returns 40x error) or RuntimeException (for 50x status)

In older versions, method $.download() returned an empty file in case of server error during downloading file. It’s certainly not convenient for testing.

Chrome browser window is also maximized.

Because of a bug in ChromeDriver Chrome browser window was not maximized. Now it is. Indeed I had to use java.awt black magic for this.

Method $.shouldHave(text()) also ignores the \u00a0 character (so called “non-breaking space”)

In older versions, a check $(".error").shouldHave(text("Hello, Johny!")) ignored spaces and tabs. But we forgot about the \u00a0 characters which is widely used in web - e.g. for formatting amounts and dates. For example, this check could fail:

  $(".amount").shouldHave(text("123.45 EUR"));

Now it works.

Improved automatic closing of browser window in case of multi-threaded tests run with TestNG

In older versions, Selenide opened and closed browser in the same thread. In most cases it’s sufficient.

But folks found that TestNG executes tests and @AfterSuite methods in different threads. We had to rework this code. Now Selenide watches all threads and automatically closes unused browser windows once corresponding threads are done.
P.S. Let me remind you that you do not need to manually close webdriver, because Selenide does it automatically.

Including webdriver exception

When a check like $.shouldBe(visible) fails because of webdriver exception, this error is not ignored anymore, but added to a standard Selenide error message like Element should be visible. It can be possible if browser behaves incorrectly. For example, folks found that IE sometimes throws InvalidSelectorException for a valid XPath.

If Selenide fails to take screenshot, it logs corresponding exception with stack trace.

Actually I am not sure that it’s really useful. To avoid spamming logs, Selenide writes stack trace only once (on the first error).

Selenide saves page source in correct encoding (UTF-8)

In older versions, Selenide could store page HTML in wrong encoding, depending on default system preferences.

Removed INFO messages about “reportsUrl” and “BUILD_URL”

Some users were confused by these messages.

Indeed, it’s a really fantastic feature: Selenide can automatically take screenshots and make them available as HTTP links in Jenkins reports. I will write a separate blog post about this feature.

Using “jQuery” word instead of “$

Sometimes Selenide used character “$” to support javascript events. It could cause problems when testing applications using both jQuery and Prototype (or some other JS framework).

Upgraded to Selenium 2.40.0, HtmlUnit 2.14 and TestNG 6.8.8

As usually, we upgraded to last versions of Selenium and TestNG.

NB! In the latest TestNG 6.8.8 was removed JUnit support. So be careful if you use both TestNG and JUnit in your project, and the latter was loaded transitively. Now you will need to add JUnit dependency explicitly.

So, life is going on!

And what’s new with you?