Changes in Selenide 2.15

Changes in Selenide 2.15

Sizzle selectors, multifile upload, BrowserMob proxy, zoom, Selenium 2.44.0
03.11.14

Good evening!

Good news: we have released Selenide 2.15. This time we have a lot of new features.

Sizzle selectors (CSS3)

Now you can use CSS3 selectors in Selenide for searching web elements!

For example:

$(":contains('Tere Martin!')").shouldBe(visible);
$(":not(a#id)");
$$(":not(div,p)").shouldHave(size(3));
$("[value!='johnny']");
$("div:has(span)");
$(":input");
$(":text");
$(":checkbox");
$(":file");
$(":password");
$(":image");
$(":header");
$(":first");
$(":last");
$(":even");

To enable Sizzle selectors, add this line to your tests:

Configuration.selectorMode = Sizzle;

Feel free to share your experience with us. Did it work for you?

Multifile upload

Now functions $.uploadFile() and $.uploadFileFromClasspath() can accept multiple arguments. This means that you can upload multiple files with Selenide!

Standard Selenium webdriver doesn’t provide such function, so we had to make it with a help of black magic. Please share your experience, if it worked for you.

Support for BrowserMob proxy

We added convenient way for Selenide to add Proxy server to webdriver. First of all, it was needed for BrowserMob proxy - a popular tool among testers. It allows to intercept http requests between web application and browser, thus making possible many things that are now allowed with pure Selenium webdriver:

  • file download from server,
  • authorization on site,
  • asserting HTTP statuses,
  • and so on

Thanks to Vladimir Denisov for this pull request!

Here is an example of using BrowserMob Proxy with Selenide ProxyServerUsageTest.java:

ProxyServer proxyServer = new ProxyServer(findFreePort());
proxyServer.start();
proxyServer.newHar("google-test");
WebDriverRunner.setProxy(proxyServer.seleniumProxy());

open("http://google.com");

List<HarEntry> harEntries = proxyServer.getHar().getLog().getEntries();
assertTrue(harEntries.get(0).getRequest().getUrl().equals("http://google.com"));


You can zoom page now!

You can find sample usage in tests:

import static com.codeborne.selenide.Selenide.*;

zoom(2.0); // Enlarge page zoom twice
zoom(0.5); // Zoom out twice

It can be useful for testing responsive design.

Support for JSON and iCal

You can now open non-html pages with Selenide.

It can be useful for testing json, iCal etc. resources. Sometimes it’s useful to check them inside UI tests.

assertThat(source(), containsString("DTSTART:20140409T090000"));

Support for tabs and windows/tabs

Now Selenide allows switching between tabs/windows/frames not only by title, but also by index (0, 1, 2, …).

Examples of switching between frames:

switchTo().frame(0);
assertTrue(source().contains("Hello, WinRar!"));

switchTo().defaultContent();
switchTo().frame(1);
$("h1").shouldHave(text("Page with dynamic select"));

Examples of switching between tabs:

switchToWindow(1); 
$("h1").shouldHave(text("Page with JQuery"));

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

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

switchToWindow(0); 
$("h1").shouldHave(text("Tabs"));

Support for Allure Framework

We have added function to get screenshot as a file:

import static com.codeborne.selenide.Screenshots.getScreenShotAsFile;

File screenshot = getScreenShotAsFile();

It can be used for integration with Allure Framework.

Thanks to Vladimir Denisov for this pull request!

Upgraded to Selenium 2.44.0.

  • Note that it brings upgrade of Google Guava to version 18.0.
  • Unfortunately, PhantomJS 1.2 does not work with Selenium webdriver 2.44.0 :( We have already committed Pull Request to ghostdriver for ghostdriver. Now waiting until it gets released.


And what’s up with you?


03.11.14