Skip to content

Commit bffd263

Browse files
committed
5378: Fix failing tests for Snackbar
1 parent 68d720a commit bffd263

File tree

5 files changed

+37
-39
lines changed

5 files changed

+37
-39
lines changed

jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.github.com.pages.ProgressSpinnerPage;
1515
import io.github.com.pages.RadioButtonPage;
1616
import io.github.com.pages.SlideTogglePage;
17+
import io.github.com.pages.SnackBarPage;
1718

1819
@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
1920
public class StaticSite {
@@ -37,10 +38,10 @@ public class StaticSite {
3738
public static BadgePage badgePage;
3839

3940
@Url("buttons_toggle")
40-
public static ButtonTogglePage buttonTogglePage;
41+
public static ButtonTogglePage buttonTogglePage;
4142

4243
@Url("divider")
43-
public static DividerPage dividerPage;
44+
public static DividerPage dividerPage;
4445

4546
@Url("autocompletes")
4647
public static AutocompletePage autocompletePage;
@@ -53,4 +54,7 @@ public class StaticSite {
5354

5455
@Url("slide_toggle")
5556
public static SlideTogglePage slideTogglePage;
57+
58+
@Url("snack_bar")
59+
public static SnackBarPage snackBarPage;
5660
}

jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.epam.jdi.light.ui.html.elements.common.Icon;
88
import io.github.com.pages.sections.GridListSection;
99
import io.github.com.pages.sections.ListSection;
10-
import io.github.com.pages.sections.SnackbarSection;
1110
import io.github.com.pages.sections.TabGroupSection;
1211
import io.github.com.pages.sections.TableSection;
1312

@@ -22,7 +21,6 @@ public class AngularPage extends WebPage {
2221
public static Dialog dialog;
2322
public static ListSection listSection;
2423
public static GridListSection gridListSection;
25-
public static SnackbarSection snackbarSection;
2624
public static TabGroupSection tabsSection;
2725
public static TableSection tableSection;
2826
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
package io.github.com.pages.sections;
1+
package io.github.com.pages;
22

33
import com.epam.jdi.light.angular.elements.complex.Snackbar;
4-
import com.epam.jdi.light.elements.composite.Section;
54
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
65
import com.epam.jdi.light.ui.html.elements.common.Button;
76
import com.epam.jdi.light.ui.html.elements.common.TextField;
87

9-
public class SnackbarSection extends Section {
10-
8+
public class SnackBarPage extends NewAngularPage {
119
@UI("#snack-bar-message-input")
1210
public TextField messageInput;
1311

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/SnackbarTests.java

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,66 @@
22

33
import com.jdiai.tools.func.JAction;
44
import io.github.epam.TestsInit;
5-
import org.testng.annotations.BeforeMethod;
6-
import org.testng.annotations.Ignore;
5+
import org.testng.annotations.BeforeClass;
76
import org.testng.annotations.Test;
87

9-
import static io.github.com.StaticSite.angularPage;
10-
import static io.github.com.pages.AngularPage.snackbarSection;
11-
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
8+
import static com.jdiai.tools.Timer.waitCondition;
9+
import static io.github.com.StaticSite.snackBarPage;
10+
1211

13-
// TODO Move to the new page
14-
@Ignore
1512
public class SnackbarTests extends TestsInit {
1613

1714
private static final String MESSAGE = "Test Message";
1815
private static final String ACTION = "Test Action";
1916

20-
@BeforeMethod
17+
@BeforeClass
2118
public void before() {
22-
shouldBeLoggedIn();
23-
angularPage.shouldBeOpened();
19+
snackBarPage.open();
20+
waitCondition(() -> snackBarPage.isOpened());
21+
snackBarPage.checkOpened();
2422
}
2523

2624
@Test
2725
public void checkBasicSnackbarTest() {
28-
snackbarSection.messageInput.setValue(MESSAGE);
29-
snackbarSection.actionInput.setValue(ACTION);
30-
snackbarSection.openButton.click();
26+
snackBarPage.messageInput.setValue(MESSAGE);
27+
snackBarPage.actionInput.setValue(ACTION);
28+
snackBarPage.openButton.click();
3129

32-
snackbarSection.basicSnackbar.is().displayed();
33-
snackbarSection.basicSnackbar.has().message(MESSAGE);
34-
snackbarSection.basicSnackbar.has().action(ACTION);
30+
snackBarPage.basicSnackbar.is().displayed();
31+
snackBarPage.basicSnackbar.has().message(MESSAGE);
32+
snackBarPage.basicSnackbar.has().action(ACTION);
3533
}
3634

3735
@Test
3836
public void checkSnackbarClickActionDismissTest() {
39-
snackbarSection.messageInput.setValue(MESSAGE);
40-
snackbarSection.actionInput.setValue(ACTION);
41-
snackbarSection.openButton.click();
37+
snackBarPage.messageInput.setValue(MESSAGE);
38+
snackBarPage.actionInput.setValue(ACTION);
39+
snackBarPage.openButton.click();
4240

43-
snackbarSection.basicSnackbar.clickAction();
44-
snackbarSection.basicSnackbar.is().disappear();
41+
snackBarPage.basicSnackbar.clickAction();
42+
snackBarPage.basicSnackbar.is().disappear();
4543
}
4644

4745
@Test
4846
public void checkSnackbarWithNoActionTest() {
49-
snackbarSection.messageInput.setValue(MESSAGE);
50-
snackbarSection.actionInput.setValue("");
51-
snackbarSection.openButton.click();
47+
snackBarPage.messageInput.setValue(MESSAGE);
48+
snackBarPage.actionInput.setValue("");
49+
snackBarPage.openButton.click();
5250

53-
snackbarSection.basicSnackbar.has().action();
51+
snackBarPage.basicSnackbar.has().action();
5452
}
5553

5654
@Test
5755
public void checkSnackbarDurationTest() {
5856
final int DURATION = 5;
5957

6058
JAction action = () -> {
61-
snackbarSection.customSnackbar.base().timer().wait(() -> snackbarSection.customSnackbar.isDisplayed());
62-
snackbarSection.customSnackbar.base().timer().wait(() -> snackbarSection.customSnackbar.isHidden());
59+
snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isDisplayed());
60+
snackBarPage.customSnackbar.base().timer().wait(() -> snackBarPage.customSnackbar.isHidden());
6361
};
6462

65-
snackbarSection.durationInput.setValue(String.valueOf(DURATION));
66-
snackbarSection.customSnackbarOpenButton.click();
63+
snackBarPage.durationInput.setValue(String.valueOf(DURATION));
64+
snackBarPage.customSnackbarOpenButton.click();
6765

6866
//duration(DURATION, 1000, action);
6967
}

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Snackbar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public class Snackbar extends UIBaseElement<SnackbarAssert> {
1313
protected UIElement message;
14-
protected String messageLocator = "./span";
14+
protected String messageLocator = "//*[@matsnackbarlabel]";
1515

1616
protected UIElement action;
1717
protected String actionLocator = ".//button";
@@ -26,7 +26,7 @@ public Snackbar() {
2626

2727
@JDIAction("Get '{name}' message")
2828
public String getMessageText() {
29-
return message.getValue();
29+
return message.getText();
3030
}
3131

3232
@JDIAction("Get '{name}' action")

0 commit comments

Comments
 (0)