Monday, September 21, 2015

Concise Selenium Tests in Java using Selenide

There are many wrappers available on Selenium to simplify writing UI tests using Selenium. Selenide is the new Selenium wrapper which supports all features of that Selenium. It allows automation developers to work with elements using jQuery style of notation. It makes Selenium code more readable, and wraps features like waits otherwise have to be written explicitly. I have tried creating a simple test using Selenide, found it's pretty simple to write tests, tests are more readable, don't have to worry for creating WebDriver object, and closing WebDriver object. I would like try Selenide for more complex tests in coming days. Here is a simple test to validate search results of Google's search page for a simple query.

package com.selenidedemo.one;

import org.testng.annotations.Test;
import static com.codeborne.selenide.Selenide.open;
import org.openqa.selenium.By;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
import static com.codeborne.selenide.Condition.text;

public class SearchTest {
    
 @Test
 public void validateSearchResults() {
  open("http://google.com/");
  $(By.name("q")).val("Mount Everest").pressEnter();
  $$("#ires .g").get(0).shouldHave(text("Mount Everest"));
 }
}

Creating Selenium tests using Selenide library easy. Download and add Selenide jar to your project and start creating the Selenium tests using Selenide functions.

Selenide web site: http://selenide.org/
Documentation: http://selenide.org/documentation.html
Quick Start: http://selenide.org/quick-start.html


Related Posts:

  • Concise Selenium Tests in Java using Selenide There are many wrappers available on Selenium to simplify writing UI tests using Selenium. Selenide is the new Selenium wrapper which supports all features of that Selenium. It allows automation developers to work with elem… Read More
  • Object Handler in Multi Platform Apps Presence of same application in multiple mobile platforms (iOS, Android etc) is quite common as application developers want to capture the market of all popular platforms. Automating your app for multiple platforms is challe… Read More
  • Design Patterns - Driver Factory One of the advantages of Selenium is it's support for multiple browsers. Mobile automation platforms like Appium support for Selenium. This makes Selenium a versatile library not only for multiple browsers, but also for mobi… Read More

2 comments:

  1. Hello,
    The Article on Concise Selenium Tests in Java using Selenide is nice give detail information about the Selenium testing tools thanks for Sharing the information about it. Software Testing Services

    ReplyDelete