From bffd26346e498ba4ea84d34ad3b85d1c9b0f98eb Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:44:23 +0600 Subject: [PATCH 01/10] 5378: Fix failing tests for Snackbar --- .../main/java/io/github/com/StaticSite.java | 8 ++- .../java/io/github/com/pages/AngularPage.java | 2 - ...SnackbarSection.java => SnackBarPage.java} | 6 +- .../tests/elements/complex/SnackbarTests.java | 56 +++++++++---------- .../angular/elements/complex/Snackbar.java | 4 +- 5 files changed, 37 insertions(+), 39 deletions(-) rename jdi-light-angular-tests/src/main/java/io/github/com/pages/{sections/SnackbarSection.java => SnackBarPage.java} (84%) diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java index 0c329d4132..51a5bfe8cf 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java @@ -14,6 +14,7 @@ import io.github.com.pages.ProgressSpinnerPage; import io.github.com.pages.RadioButtonPage; import io.github.com.pages.SlideTogglePage; +import io.github.com.pages.SnackBarPage; @JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/") public class StaticSite { @@ -37,10 +38,10 @@ public class StaticSite { public static BadgePage badgePage; @Url("buttons_toggle") - public static ButtonTogglePage buttonTogglePage; + public static ButtonTogglePage buttonTogglePage; @Url("divider") - public static DividerPage dividerPage; + public static DividerPage dividerPage; @Url("autocompletes") public static AutocompletePage autocompletePage; @@ -53,4 +54,7 @@ public class StaticSite { @Url("slide_toggle") public static SlideTogglePage slideTogglePage; + + @Url("snack_bar") + public static SnackBarPage snackBarPage; } diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java index 776bc1c465..690b23fdd7 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java @@ -7,7 +7,6 @@ import com.epam.jdi.light.ui.html.elements.common.Icon; import io.github.com.pages.sections.GridListSection; import io.github.com.pages.sections.ListSection; -import io.github.com.pages.sections.SnackbarSection; import io.github.com.pages.sections.TabGroupSection; import io.github.com.pages.sections.TableSection; @@ -22,7 +21,6 @@ public class AngularPage extends WebPage { public static Dialog dialog; public static ListSection listSection; public static GridListSection gridListSection; - public static SnackbarSection snackbarSection; public static TabGroupSection tabsSection; public static TableSection tableSection; } diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SnackbarSection.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/SnackBarPage.java similarity index 84% rename from jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SnackbarSection.java rename to jdi-light-angular-tests/src/main/java/io/github/com/pages/SnackBarPage.java index 6583b5e363..7af52cdb92 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SnackbarSection.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/SnackBarPage.java @@ -1,13 +1,11 @@ -package io.github.com.pages.sections; +package io.github.com.pages; import com.epam.jdi.light.angular.elements.complex.Snackbar; -import com.epam.jdi.light.elements.composite.Section; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; import com.epam.jdi.light.ui.html.elements.common.Button; import com.epam.jdi.light.ui.html.elements.common.TextField; -public class SnackbarSection extends Section { - +public class SnackBarPage extends NewAngularPage { @UI("#snack-bar-message-input") public TextField messageInput; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index 5fa5fcd158..b346e67ef1 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -2,55 +2,53 @@ import com.jdiai.tools.func.JAction; import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.snackbarSection; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.snackBarPage; + -// TODO Move to the new page -@Ignore public class SnackbarTests extends TestsInit { private static final String MESSAGE = "Test Message"; private static final String ACTION = "Test Action"; - @BeforeMethod + @BeforeClass public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); + snackBarPage.open(); + waitCondition(() -> snackBarPage.isOpened()); + snackBarPage.checkOpened(); } @Test public void checkBasicSnackbarTest() { - snackbarSection.messageInput.setValue(MESSAGE); - snackbarSection.actionInput.setValue(ACTION); - snackbarSection.openButton.click(); + snackBarPage.messageInput.setValue(MESSAGE); + snackBarPage.actionInput.setValue(ACTION); + snackBarPage.openButton.click(); - snackbarSection.basicSnackbar.is().displayed(); - snackbarSection.basicSnackbar.has().message(MESSAGE); - snackbarSection.basicSnackbar.has().action(ACTION); + snackBarPage.basicSnackbar.is().displayed(); + snackBarPage.basicSnackbar.has().message(MESSAGE); + snackBarPage.basicSnackbar.has().action(ACTION); } @Test public void checkSnackbarClickActionDismissTest() { - snackbarSection.messageInput.setValue(MESSAGE); - snackbarSection.actionInput.setValue(ACTION); - snackbarSection.openButton.click(); + snackBarPage.messageInput.setValue(MESSAGE); + snackBarPage.actionInput.setValue(ACTION); + snackBarPage.openButton.click(); - snackbarSection.basicSnackbar.clickAction(); - snackbarSection.basicSnackbar.is().disappear(); + snackBarPage.basicSnackbar.clickAction(); + snackBarPage.basicSnackbar.is().disappear(); } @Test public void checkSnackbarWithNoActionTest() { - snackbarSection.messageInput.setValue(MESSAGE); - snackbarSection.actionInput.setValue(""); - snackbarSection.openButton.click(); + snackBarPage.messageInput.setValue(MESSAGE); + snackBarPage.actionInput.setValue(""); + snackBarPage.openButton.click(); - snackbarSection.basicSnackbar.has().action(); + snackBarPage.basicSnackbar.has().action(); } @Test @@ -58,12 +56,12 @@ public void checkSnackbarDurationTest() { final int DURATION = 5; JAction action = () -> { - snackbarSection.customSnackbar.base().timer().wait(() -> snackbarSection.customSnackbar.isDisplayed()); - snackbarSection.customSnackbar.base().timer().wait(() -> snackbarSection.customSnackbar.isHidden()); + snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isDisplayed()); + snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isHidden()); }; - snackbarSection.durationInput.setValue(String.valueOf(DURATION)); - snackbarSection.customSnackbarOpenButton.click(); + snackBarPage.durationInput.setValue(String.valueOf(DURATION)); + snackBarPage.customSnackbarOpenButton.click(); //duration(DURATION, 1000, action); } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index c72973dfb0..9a7accff2e 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -11,7 +11,7 @@ public class Snackbar extends UIBaseElement { protected UIElement message; - protected String messageLocator = "./span"; + protected String messageLocator = "//*[@matsnackbarlabel]"; protected UIElement action; protected String actionLocator = ".//button"; @@ -26,7 +26,7 @@ public Snackbar() { @JDIAction("Get '{name}' message") public String getMessageText() { - return message.getValue(); + return message.getText(); } @JDIAction("Get '{name}' action") From 5bcaab1a6a0a6f715759ebe87363d3c4a3c0a2e7 Mon Sep 17 00:00:00 2001 From: igor-korost <74544655+igor-korost@users.noreply.github.com> Date: Wed, 31 Jan 2024 19:47:03 +0600 Subject: [PATCH 02/10] Update jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java Co-authored-by: Natalia Pozhidaeva --- .../com/epam/jdi/light/angular/elements/complex/Snackbar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index 9a7accff2e..5f32bdfdc4 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -25,7 +25,7 @@ public Snackbar() { } @JDIAction("Get '{name}' message") - public String getMessageText() { + public String messageText() { return message.getText(); } From 952c65c7f94cd1e5ee92076768c46dd65fff617d Mon Sep 17 00:00:00 2001 From: igor-korost <74544655+igor-korost@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:03:25 +0600 Subject: [PATCH 03/10] Update jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java Co-authored-by: Natalia Pozhidaeva --- .../epam/angular/tests/elements/complex/SnackbarTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index b346e67ef1..8bf461e4c0 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -38,7 +38,7 @@ public void checkSnackbarClickActionDismissTest() { snackBarPage.actionInput.setValue(ACTION); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.clickAction(); + snackBarPage.basicSnackbar.action().click(); snackBarPage.basicSnackbar.is().disappear(); } From 234d2523c749d3b9a7d05ed810578d7b4bf5a774 Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:12:28 +0600 Subject: [PATCH 04/10] 5378 Fix review --- .../angular/tests/elements/complex/SnackbarTests.java | 6 ++---- .../epam/jdi/light/angular/asserts/SnackbarAssert.java | 9 +++++---- .../jdi/light/angular/elements/complex/Snackbar.java | 9 +++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index 8bf461e4c0..eb67037473 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -38,7 +38,7 @@ public void checkSnackbarClickActionDismissTest() { snackBarPage.actionInput.setValue(ACTION); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.action().click(); + snackBarPage.basicSnackbar.action.click(); snackBarPage.basicSnackbar.is().disappear(); } @@ -48,7 +48,7 @@ public void checkSnackbarWithNoActionTest() { snackBarPage.actionInput.setValue(""); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.has().action(); + snackBarPage.basicSnackbar.has().noAction(); } @Test @@ -62,7 +62,5 @@ public void checkSnackbarDurationTest() { snackBarPage.durationInput.setValue(String.valueOf(DURATION)); snackBarPage.customSnackbarOpenButton.click(); - - //duration(DURATION, 1000, action); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java index 2f2d0da173..739f9a8c31 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java @@ -11,19 +11,20 @@ public class SnackbarAssert extends UIAssert { @JDIAction(value = "Assert that '{name}' has message '{0}'", isAssert = true) public SnackbarAssert message(String expected) { - jdiAssert(element().getMessageText(), Matchers.is(expected)); + jdiAssert(element().messageText(), Matchers.is(expected)); return this; } @JDIAction(value = "Assert that '{name}' has no action", isAssert = true) - public SnackbarAssert action() { - jdiAssert(element().isActionDisplayed(), Matchers.is(false), "ERROR MESSAGE IS REQUIRED"); + public SnackbarAssert noAction() { + jdiAssert(element().isDisplayed(), Matchers.is(true), "No snackbar element found"); + jdiAssert(element().isActionDisplayed(), Matchers.is(false), "Action button should be absent"); return this; } @JDIAction(value = "Assert that '{name}' has action {0}", isAssert = true) public SnackbarAssert action(String expected) { - jdiAssert(element().getActionText(), Matchers.is(expected)); + jdiAssert(element().actionText(), Matchers.is(expected)); return this; } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index 5f32bdfdc4..f6ca539e3a 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -4,6 +4,7 @@ import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; +import com.epam.jdi.light.ui.html.elements.common.Button; /** * To see an example of Snackbar web element please visit https://material.angular.io/components/snack-bar/overview. @@ -13,14 +14,14 @@ public class Snackbar extends UIBaseElement { protected UIElement message; protected String messageLocator = "//*[@matsnackbarlabel]"; - protected UIElement action; - protected String actionLocator = ".//button"; + public Button action; + protected String actionLocator = "//button"; public Snackbar() { message = new UIElement(); message.core().setLocator(messageLocator); - action = new UIElement(); + action = new Button(); action.core().setLocator(actionLocator); } @@ -30,7 +31,7 @@ public String messageText() { } @JDIAction("Get '{name}' action") - public String getActionText() { + public String actionText() { return action.getValue(); } From c5013797ea53e69ea149742c22b4c653cd2e11b8 Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Fri, 2 Feb 2024 14:50:52 +0600 Subject: [PATCH 05/10] 5378 Fix locator --- .../com/epam/jdi/light/angular/elements/complex/Snackbar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index f6ca539e3a..c092eee0d1 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -15,7 +15,7 @@ public class Snackbar extends UIBaseElement { protected String messageLocator = "//*[@matsnackbarlabel]"; public Button action; - protected String actionLocator = "//button"; + protected String actionLocator = ".//button"; public Snackbar() { message = new UIElement(); From 16c6929c0a28fab651d09a2313923777e920716e Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:21:37 +0600 Subject: [PATCH 06/10] 5378 Fix review --- .../tests/elements/complex/SnackbarTests.java | 7 +++--- .../light/angular/asserts/SnackbarAssert.java | 13 ----------- .../angular/elements/complex/Snackbar.java | 23 ++++--------------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index eb67037473..79bb5ef8c4 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -29,7 +29,7 @@ public void checkBasicSnackbarTest() { snackBarPage.basicSnackbar.is().displayed(); snackBarPage.basicSnackbar.has().message(MESSAGE); - snackBarPage.basicSnackbar.has().action(ACTION); + snackBarPage.basicSnackbar.actionButton.has().text(ACTION); } @Test @@ -38,7 +38,7 @@ public void checkSnackbarClickActionDismissTest() { snackBarPage.actionInput.setValue(ACTION); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.action.click(); + snackBarPage.basicSnackbar.actionButton.click(); snackBarPage.basicSnackbar.is().disappear(); } @@ -48,7 +48,8 @@ public void checkSnackbarWithNoActionTest() { snackBarPage.actionInput.setValue(""); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.has().noAction(); + snackBarPage.basicSnackbar.has().shown(); + snackBarPage.basicSnackbar.actionButton.has().notAppear(); } @Test diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java index 739f9a8c31..1ed0dc9808 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java @@ -14,17 +14,4 @@ public SnackbarAssert message(String expected) { jdiAssert(element().messageText(), Matchers.is(expected)); return this; } - - @JDIAction(value = "Assert that '{name}' has no action", isAssert = true) - public SnackbarAssert noAction() { - jdiAssert(element().isDisplayed(), Matchers.is(true), "No snackbar element found"); - jdiAssert(element().isActionDisplayed(), Matchers.is(false), "Action button should be absent"); - return this; - } - - @JDIAction(value = "Assert that '{name}' has action {0}", isAssert = true) - public SnackbarAssert action(String expected) { - jdiAssert(element().actionText(), Matchers.is(expected)); - return this; - } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index c092eee0d1..ca87120589 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -12,17 +12,17 @@ public class Snackbar extends UIBaseElement { protected UIElement message; - protected String messageLocator = "//*[@matsnackbarlabel]"; + protected String messageLocator = ".mdc-snackbar__label"; - public Button action; + public Button actionButton; protected String actionLocator = ".//button"; public Snackbar() { message = new UIElement(); message.core().setLocator(messageLocator); - action = new Button(); - action.core().setLocator(actionLocator); + actionButton = new Button(); + actionButton.core().setLocator(actionLocator); } @JDIAction("Get '{name}' message") @@ -30,21 +30,6 @@ public String messageText() { return message.getText(); } - @JDIAction("Get '{name}' action") - public String actionText() { - return action.getValue(); - } - - @JDIAction("Click '{name}' action") - public void clickAction() { - action.click(); - } - - @JDIAction("Is '{name}' action displayed") - public boolean isActionDisplayed() { - return action.isDisplayed(); - } - @Override public SnackbarAssert is() { return new SnackbarAssert().set(this); From e919568b642615b09c0521e73ff974fb66b1bcdd Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:28:21 +0600 Subject: [PATCH 07/10] 5378 Fix review --- .../tests/elements/complex/SnackbarTests.java | 6 +++--- .../light/angular/asserts/SnackbarAssert.java | 2 +- .../angular/elements/complex/Snackbar.java | 17 +++++------------ .../main/java/pseudo/site/forms/CustomForm.java | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index 79bb5ef8c4..d742fe8631 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -29,7 +29,7 @@ public void checkBasicSnackbarTest() { snackBarPage.basicSnackbar.is().displayed(); snackBarPage.basicSnackbar.has().message(MESSAGE); - snackBarPage.basicSnackbar.actionButton.has().text(ACTION); + snackBarPage.basicSnackbar.actionButton().has().text(ACTION); } @Test @@ -38,7 +38,7 @@ public void checkSnackbarClickActionDismissTest() { snackBarPage.actionInput.setValue(ACTION); snackBarPage.openButton.click(); - snackBarPage.basicSnackbar.actionButton.click(); + snackBarPage.basicSnackbar.actionButton().click(); snackBarPage.basicSnackbar.is().disappear(); } @@ -49,7 +49,7 @@ public void checkSnackbarWithNoActionTest() { snackBarPage.openButton.click(); snackBarPage.basicSnackbar.has().shown(); - snackBarPage.basicSnackbar.actionButton.has().notAppear(); + snackBarPage.basicSnackbar.actionButton().has().notAppear(); } @Test diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java index 1ed0dc9808..98a1931320 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java @@ -11,7 +11,7 @@ public class SnackbarAssert extends UIAssert { @JDIAction(value = "Assert that '{name}' has message '{0}'", isAssert = true) public SnackbarAssert message(String expected) { - jdiAssert(element().messageText(), Matchers.is(expected)); + jdiAssert(element().messageText(), Matchers.containsString(expected)); return this; } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java index ca87120589..f4d265aa4a 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java @@ -3,7 +3,6 @@ import com.epam.jdi.light.angular.asserts.SnackbarAssert; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; -import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.ui.html.elements.common.Button; /** @@ -11,23 +10,17 @@ */ public class Snackbar extends UIBaseElement { - protected UIElement message; protected String messageLocator = ".mdc-snackbar__label"; - - public Button actionButton; protected String actionLocator = ".//button"; - public Snackbar() { - message = new UIElement(); - message.core().setLocator(messageLocator); - - actionButton = new Button(); - actionButton.core().setLocator(actionLocator); + @JDIAction("Get '{name}' message") + public Button actionButton() { + return new Button().setCore(Button.class, core().find(this.actionLocator)); } - @JDIAction("Get '{name}' message") + @JDIAction("Get Snackbar message") public String messageText() { - return message.getText(); + return this.find(messageLocator).getText(); } @Override diff --git a/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java b/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java index c26adc4abd..d046911b6d 100644 --- a/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java +++ b/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java @@ -262,7 +262,7 @@ public List getXpathPublicUIElementList() { } public Button getCssButton() { - return cssButton; + return cssButton.setCore(); } public Button getXpathPublicButton() { From 90b4fe2dd51f3d951aff11c2b5aafa8c09d6a529 Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:50:38 +0600 Subject: [PATCH 08/10] 5378 Fix typo --- .../src/main/java/pseudo/site/forms/CustomForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java b/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java index d046911b6d..c26adc4abd 100644 --- a/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java +++ b/jdi-light-html-tests/src/main/java/pseudo/site/forms/CustomForm.java @@ -262,7 +262,7 @@ public List getXpathPublicUIElementList() { } public Button getCssButton() { - return cssButton.setCore(); + return cssButton; } public Button getXpathPublicButton() { From 3058d291a0bb430efdbff2e8087f16a1be8db679 Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:35:26 +0500 Subject: [PATCH 09/10] Update Cypress --- .../tests/elements/complex/SnackbarTests.java | 18 ++++++++++++------ .../src/test/resources/common.properties | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index d742fe8631..8e2ead76b2 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -54,14 +54,20 @@ public void checkSnackbarWithNoActionTest() { @Test public void checkSnackbarDurationTest() { - final int DURATION = 5; - - JAction action = () -> { - snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isDisplayed()); - snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isHidden()); - }; + final int DURATION = 5; // Duration in seconds + // Set the duration for the snackbar visibility snackBarPage.durationInput.setValue(String.valueOf(DURATION)); + + // Open the custom snackbar snackBarPage.customSnackbarOpenButton.click(); + + // Wait for the snackbar to be displayed + snackBarPage.customSnackbar.base().timer().waitFor(() -> snackBarPage.customSnackbar.isDisplayed(), DURATION, "Snackbar did not appear in expected time"); + + // Then, wait for the snackbar to disappear. + // Assuming snackbar visibility duration is DURATION, add a buffer to wait for disappearance. + int waitTimeForDisappearance = DURATION + 2; // Adding a buffer time for it to disappear + snackBarPage.customSnackbar.base().timer().waitFor(() -> snackBarPage.customSnackbar.isHidden(), waitTimeForDisappearance, "Snackbar did not disappear in expected time"); } } diff --git a/jdi-light-angular-tests/src/test/resources/common.properties b/jdi-light-angular-tests/src/test/resources/common.properties index c31a28a764..91b3603f15 100644 --- a/jdi-light-angular-tests/src/test/resources/common.properties +++ b/jdi-light-angular-tests/src/test/resources/common.properties @@ -1 +1 @@ -arguments=--headless +arguments=--headed From c6e5fb5a0e572018f1dff904891a4427528b6fdf Mon Sep 17 00:00:00 2001 From: Igor Korostelev <74544655+igor-korost@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:39:59 +0500 Subject: [PATCH 10/10] Revert "Update Cypress" This reverts commit 3058d291a0bb430efdbff2e8087f16a1be8db679. --- .../tests/elements/complex/SnackbarTests.java | 18 ++++++------------ .../src/test/resources/common.properties | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java index 8e2ead76b2..d742fe8631 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java @@ -54,20 +54,14 @@ public void checkSnackbarWithNoActionTest() { @Test public void checkSnackbarDurationTest() { - final int DURATION = 5; // Duration in seconds + final int DURATION = 5; - // Set the duration for the snackbar visibility - snackBarPage.durationInput.setValue(String.valueOf(DURATION)); + JAction action = () -> { + snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isDisplayed()); + snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isHidden()); + }; - // Open the custom snackbar + snackBarPage.durationInput.setValue(String.valueOf(DURATION)); snackBarPage.customSnackbarOpenButton.click(); - - // Wait for the snackbar to be displayed - snackBarPage.customSnackbar.base().timer().waitFor(() -> snackBarPage.customSnackbar.isDisplayed(), DURATION, "Snackbar did not appear in expected time"); - - // Then, wait for the snackbar to disappear. - // Assuming snackbar visibility duration is DURATION, add a buffer to wait for disappearance. - int waitTimeForDisappearance = DURATION + 2; // Adding a buffer time for it to disappear - snackBarPage.customSnackbar.base().timer().waitFor(() -> snackBarPage.customSnackbar.isHidden(), waitTimeForDisappearance, "Snackbar did not disappear in expected time"); } } diff --git a/jdi-light-angular-tests/src/test/resources/common.properties b/jdi-light-angular-tests/src/test/resources/common.properties index 91b3603f15..c31a28a764 100644 --- a/jdi-light-angular-tests/src/test/resources/common.properties +++ b/jdi-light-angular-tests/src/test/resources/common.properties @@ -1 +1 @@ -arguments=--headed +arguments=--headless