From c64410d682e8777640a0e55bb71cf76398ebc9bd Mon Sep 17 00:00:00 2001 From: mfaisalkhatri Date: Sat, 16 May 2026 16:06:12 +0530 Subject: [PATCH] added assertion to clickWithModifier Test --- .../tests/ClickOperationTests.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/test/java/io/github/mfaisalkhatri/tests/ClickOperationTests.java b/src/test/java/io/github/mfaisalkhatri/tests/ClickOperationTests.java index 1b6442f..7dfe873 100644 --- a/src/test/java/io/github/mfaisalkhatri/tests/ClickOperationTests.java +++ b/src/test/java/io/github/mfaisalkhatri/tests/ClickOperationTests.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.List; +import java.util.regex.Pattern; import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; import static org.testng.Assert.assertEquals; @@ -110,21 +111,24 @@ public void testClickWithModifiers () { FrameLocator frame = this.page.frameLocator (".demo-frame"); Locator items = frame.locator ("#selectable li"); + Locator itemOne = items.nth (0); + Locator itemFour = items.nth (3); - items.nth (0) - .click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.CONTROL))); + itemOne.click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.CONTROL))); - items.nth (3) - .click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.CONTROL))); + itemFour.click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.CONTROL))); - this.page.waitForTimeout (2000); + assertThat (itemOne).hasClass (Pattern.compile (".*ui-selected.*")); + assertThat (itemFour).hasClass (Pattern.compile (".*ui-selected.*")); - this.page.navigate ("https://the-internet.herokuapp.com/"); - this.page.getByRole (AriaRole.LINK, new Page.GetByRoleOptions ().setName ("File Download") - .setExact (true)) - .click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.SHIFT))); + // this.page.waitForTimeout (2000); - this.page.waitForTimeout (2000); + // this.page.navigate ("https://the-internet.herokuapp.com/"); + // this.page.getByRole (AriaRole.LINK, new Page.GetByRoleOptions ().setName ("File Download") + // .setExact (true)) + // .click (new Locator.ClickOptions ().setModifiers (List.of (KeyboardModifier.SHIFT))); + // + // this.page.waitForTimeout (2000); }