Selenide Introduction
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.
Adding Selenide Maven dependency to the project -
<dependency> <groupId>com.codeborne</groupId> <artifactId>selenide</artifactId> <version>6.10.2</version> </dependency>
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 :
Maven - Build Automation Tool
IDE - Here, I'm using VSCode (any IDE works)
TestNG - We can integrate with JUnit too
Selenide