Selenide: Quick Start
Selenide is a Selenium wrapper in Java for testing.
This post describes how you can start using Selenide (using Gradle).
1. Setup Java Application
# keep pressing enters to choose default values
gradle init --type java-application
# confirm that test succeeds
gradle test
2. Add Selenide Dependency
open build.gradle and edit as:
dependencies {
...
testImplementation 'com.codeborne:selenide:5.13.0'
}
3. Write Test (replace the existing test with selenide code)
src/test/java/selenide/AppTest.java
package selenide;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
import org.junit.Test;
public class AppTest {
@Test
public void test() {
open("https://www.google.ca/");
$("input[type=text]").val("test").pressEnter();
$("body").shouldHave(text("test"));
}
}
4. Run Selenide
gradle test
This will open a browser to:
- access google.ca
- type "test" and press enter
- check if the result includes "test"
Comments
Post a Comment