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] 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")