Selenide Introduction

ยท

2 min read

Created by Andrei Solntsev

What is Selenide?

  • Wrapper for Selenium WebDriver which allows users to write easier, faster UI Tests.

  • This solves different problems related to Selenium Webdriver, a few of them are; Thread Safety, Run-Time Exceptions, Timeouts, etc.

  • This is very stable, holds inbuilt assertions, crisp API.

๐Ÿค– Features :

It Automatically handles the below attributes ๐Ÿ‘‡

  • Ajax, timeouts, wait of elements.

  • Screenshots on a Test Failure and a few more.

  • Focuses only on business logic but not on minor problems.

๐Ÿ–ฅ Sample Test Code :

@Test
public void testLogin() {
  open("/login");
  $(By.name("user.name")).sendKeys("johny");
  $("#submitButton").click();
  $("#username").shouldHave(text("Hello, Johny!"));
  $(".error").shouldNotBe(visible);
}

When the above code is executed, Selenide launches the specified URL in the web browser via an open keyword, performs checks or actions as stated and automatically closes, when the tests are completed.

Isn't this cool? Let's try to start writing.

  1. Adding Selenide Maven dependency to the project -

    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>selenide</artifactId>
        <version>6.10.2</version>
    </dependency>
    
  2. Importing required static classes -

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

and done. Now, we're ready to write our tests using Selenide! ๐Ÿคฉ

Requirements :

  1. Maven - Build Automation Tool

  2. IDE - Here, I'm using VSCode (any IDE works)

  3. TestNG - We can integrate with JUnit too

  4. Selenide

References