|
| 1 | +package io.github.mfaisalkhatri.tests; |
| 2 | + |
| 3 | +import com.microsoft.playwright.*; |
| 4 | +import com.microsoft.playwright.options.AriaRole; |
| 5 | +import org.testng.annotations.AfterClass; |
| 6 | +import org.testng.annotations.BeforeClass; |
| 7 | +import org.testng.annotations.Test; |
| 8 | + |
| 9 | +import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; |
| 10 | + |
| 11 | +public class TestElementState { |
| 12 | + |
| 13 | + private Playwright playwright; |
| 14 | + private Page page; |
| 15 | + |
| 16 | + |
| 17 | + @BeforeClass |
| 18 | + public void setup() { |
| 19 | + this.playwright = Playwright.create(); |
| 20 | + final Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false).setChannel("chrome")); |
| 21 | + this.page = browser.newPage(); |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + public void testElementIsDisabled() { |
| 26 | + page.navigate("https://the-internet.herokuapp.com/jqueryui/menu#"); |
| 27 | + Locator disabledMenu = page.locator("#ui-id-1 > a"); |
| 28 | + assertThat(disabledMenu).isDisabled(); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void testElementIsEnabled() { |
| 33 | + page.navigate("https://the-internet.herokuapp.com/jqueryui/menu#"); |
| 34 | + Locator enabledMenu = page.locator("#ui-id-3 > a"); |
| 35 | + assertThat(enabledMenu).isEnabled(); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void testElementIsDisplayed() { |
| 40 | + page.navigate("https://www.lambdatest.com/selenium-playground/"); |
| 41 | + |
| 42 | + Locator radioButtonLink = page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Radio Buttons Demo")); |
| 43 | + radioButtonLink.click(); |
| 44 | + Locator pageHeading = page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("Radio button Demo")); |
| 45 | + assertThat(pageHeading).isVisible(); |
| 46 | + assertThat(pageHeading).equals("Radio button Demo"); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testElementIsSelected() { |
| 51 | + |
| 52 | + } |
| 53 | + |
| 54 | + @AfterClass |
| 55 | + public void tearDown() { |
| 56 | + this.page.close(); |
| 57 | + this.playwright.close(); |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments