Changes in Selenide 2.10

✓ Selenium 3.0.0 ✓ Java 8


Changes in Selenide 2.10

Windows, tabs, DragAndDrop, JavaScript errors, parent search and upgrade to Selenium 2.41.0

Hi all!

Recently we released Selenide 2.10. Let me introduce you the news!

New functions

Working with windows/tabs

Selenium WebDriver does not support convenient API for working with windows and tabs. It only suggests method getWindowHandles() that returns set of strings - identifiers of opened windows. It’s not trivial to find the needed one from these handles.

As Selenide primary goal is to free developer’s head from browser technical details, we want to make working with windows/tabs easy and intuitive. We started this movement from a simple thing: we have added method

Selenide.switchToWindow(String title)

You can find a sample usage in Selenide tests:

  public void canSwitchToWindowByTitle() {
    $(byText("Page2: alerts")).click();
    $(byText("Page1: uploads")).click();

    $("h1").shouldHave(text("Page with alerts"));

    $("h1").shouldHave(text("File uploads"));

We are planning to continue working on simplifying windows/tabs API - probably with help of new Java 8 features.

How would you like to use windows? Please feel free to share your ideas!

New methods $.hover() и $.dragAndDropTo(target)

Method $.hover() emulates moving mouse over the element (without clicking). Find example here.

Method $.dragAndDropTo(target) can drag an element and drop into another element. Example:


New methods for searching parent/ancestors $.parent() and $.closest()

I often need to get a parent element. Or even ancestor, not direct parent. For example, I often search a DIV by text - this DIV is located inside a table. Then I want to find the table row containing the DIV. The only way to find it was using XPATH.

Now you can use convenient $.parent() or $.closest() methods:

  $(byText("Row 1")).parent();
  $(byText("Row 2")).closest("tr");

You can find more examples here

Tracing JavaScript errors

Now Selenide tries to automatically catch all JavaScript errors that happened on a page.

What we do we them?

First of all, Selenide automatically adds JS errors to the error message when your test fails. Basically, it’s sufficient. If you want more control, you can use the following methods:

  • Selenide.getJavascriptErrors() - returns all JavaScript errors on current page.
  • Selenide.assertNoJavascriptErrors() - fails the test if there have been some JavaScript errors on current page.

P.S. By now it’s implemented very simply (using the window.onerror function). I am not sure it works pretty well in all browsers. And it cannot catch all errors. So, feel free to share you ideas how to implement it better.

Bugfixes and improvements

### Closing webdrivers Mechanism of automatic closing webdrivers was improved for case when one of webdrivers is hanging (and thus cannot be closed and prevents closing of other webdrivers). Thanks to Aleksander Gavrilenko for this nontrivial fix!

Selenide does not wait for <body>

Method open(url) doesn’t wait until the tag <body> appears in the document. This is just an old code that is not needed since Selenide automatically waits for required conditions.

Upgrade to Selenium 2.41.0

As usually, we upgraded to latest Selenium WebDriver version.

We haven’t observed any problems with the new Selenium. It works.

Other news

March statistics of Selenide downloads is just great!

We became twice as much during one month! Wow!

And what’s new with you?

blog comments powered by Disqus

The project is maintained by