Tuesday, 19 July 2016

My first program with Selenide:


Create a Maven project.

Add selenium-java client dependencies in pom.xml

Add TestNG or JUnit dependencies in pom.xml

And finally Selenide dependencies

<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>selenide</artifactId>
    <version>3.7</version>
    <scope>test</scope>
</dependency>


Add a simple TestNG/ Junit class

import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;
public class Test
{
@Test
public void userCanLoginByUsername() {
  open("/login");
  $(By.name("user.name")).setValue("johny");
  $("#submit").click();
  $(".loading_progress").should(disappear); 
  $("#username").shouldHave(text("Hello, Johny!")); 
}
}
 


Just Run it.

No comments:

Post a Comment