A Really Quick Start with Selenide

This year I’ve learned Selenide, the Selenium WebDriver based framework that helps you to write compact and concise automation code in java. I’ve talked to Andrei Solntsev who is the author of the framework and watched some of his talks, realizing deep understanding of testing and development processes from the Selenide developers. So let’s just use it!

Wait a moment, there is a litte problem. If you visit “Quick Start” section of the site, you will get some code snippet suggesting, you should use on of the advanced development tools like maven, gradle or ivy. Is it really a must? Not at all! To get started and write effective test with Selenide you need only the basics of test automations: Java, Eclipse and a bit of Selenium. Do you have spare 5–10 minutes? It’s enough, just have a look.

We will need:

  1. Download the latest version Selenium Client for Java (http://www.seleniumhq.org/download/ ) and selenide.jar ( find the latest http://search.maven.org/#search%7Cga%7C1%7Cselenide and download .jar).
     Update (a bit quicker): instead of Selenium Client for Java download Selenium Server — selenium-server-standalone-x.y.z.jar ~35Mb
  2. Start Eclipse and create new Java Project (File->New->Java Project). Enter project name e.g. SelenideQuickStart. Press Finish.
  1. Unpack selenium-java-x.y.z.zip and add all jars (selenium-java-x.y.z.jar, and content of lib folder), as well as selenide-x.y.jar to the project (Project Properties -> Java Build Path -> Libraries).
  1. Update. If you downloaded selenium-server-standalone-x.y.z.jar, just add it instead of the Selenium Client for Java, to have the list much shorter:
  1. Server edition of Selenium (.jar) contains fully unpacked jar-files of the client edition along with additional classes & packages, it is sometime more difficult to resolve conflicts with third-party libraries, if you testing project needs them. Fortunately, testing projects rarely depend on the other third-party jars, so it should be not a problem for automation.
  2. Create JUnit test (File->New>JUnit Test Case). Choose JUnit Test 4, enter package, e.g. com.selenide.quickstart and the test class name, e.g. GoogleTest. Press Finish.
  1. Agree to add JUnit 4 to the project.
  1. Exchange the standard test code for the following. This test enters “selenide” into Google search field, compares the results and takes a screenshot of the result page.
  2. packagecom.selenide.quickstart;
  3. // import Selenide Classes
  4. import staticcom.codeborne.selenide.Condition.*;
  5. import staticcom.codeborne.selenide.Selenide.*;
  6. import org.junit.Test;
  7. import org.openqa.selenium.By;
  8. publicclassGoogleTest
  9. @Test
  10. publicvoidsearchGoogle()
  11. // open google start page
  12. open(“http://google.com");
  13. // enter “selenide” in the search field (CSS Selector q)
  14. // and press Enter
  15. $(By.name(“q”)).val(“selenide”)
  16. .pressEnter();
  17. // first element should be visible
  18. // and contain the following text
  19. $(“#ires li.g”).shouldBe(visible)
  20. .shouldHave(text(“Selenide: concise UI tests in Java”));
  21. // makes screenshot of the result’s page
  22. screenshot(“google_results”);
  23. We are done! Start test (as JUnit Test) Run->Run. The Firefox browser opens for a few seconds and runs the test. Look at the result:
  1. Let’s find the screenshot. Selenide saves png-image and html-page in the folder build/reports/tests. You can open it e.g. in Navigator (Window->Show View->Navigator). Sometime you need to refresh the view with F5 (or File->Refresh).


We have written he working test with Selenide within a few minutes, avoiding learning the deepth of the developers’ frameworks.

Got curios? Watch the video from the authors (1 hour) to learn the advanced features of the Selenide.

Or do you want to quickly write concise Selenium based tests without any IDE? Subscribe to my blog, I am going to write about it soon!

Originally published at blog.vinogradov-it.de on December 29, 2014.