diff --git a/src/test/java/com/saddy/tests/SampleTest.java b/src/test/java/com/saddy/tests/SampleTest.java index 9fe5270..a8ccde3 100644 --- a/src/test/java/com/saddy/tests/SampleTest.java +++ b/src/test/java/com/saddy/tests/SampleTest.java @@ -1,29 +1,41 @@ package com.saddy.tests; -import com.seleniumboot.listeners.Retryable; +import com.seleniumboot.locator.Role; import com.seleniumboot.test.BaseTest; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; - +/** + * The first test most people read. It is deliberately the smallest useful example of + * what Selenium Boot actually gives you over plain Selenium: + * + *
Raw Selenium is never hidden: {@code getDriver()} is always there when you need it. + * See {@code LocatorApiDemoTest} for the full locator surface. + */ public class SampleTest extends BaseTest { - @Test - public void testSampleDemo() { - getDriver().get("https://google.com"); - assertEquals(getDriver().getTitle(), "Google"); - } - @Test - public void testScreenshotOnFailure() { - getDriver().get("https://google.com"); - assertEquals(getDriver().getTitle(), "Google"); + @Test(description = "Find and fill a form without a single CSS selector") + public void signsInUsingAccessibleLocators() { + open(); + + getByLabel("Username").type("admin"); + getByLabel("Password").type("password"); + + assertThat(getByLabel("Username")).hasValue("admin"); + assertThat(getByRole(Role.BUTTON, "Login")).isVisible(); } -// @Retryable -// @Test(description = "This is a flaky Test") -// public void flakyTest() { -// if (Math.random() < 0.7) { -// throw new RuntimeException("Random failure"); -// } -// } + @Test(description = "Locate by test id — survives any CSS or DOM refactor") + public void findsElementsByTestId() { + open(); + + assertThat(getByTestId("login-submit-btn")).isVisible(); + assertThat(getByTestId("remember-checkbox")).isVisible(); + } }