Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -53,4 +54,7 @@ public class StaticSite {

@Url("slide_toggle")
public static SlideTogglePage slideTogglePage;

@Url("snack_bar")
public static SnackBarPage snackBarPage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,66 @@

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тест про NO ACTION TEST
но в валидации проверяем, что action есть - не логично

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переименовал. Теперь эта строчка выглядит так snackBarPage.basicSnackbar.has().noAction();

}

@Test
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалить

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделано

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Snackbar extends UIBaseElement<SnackbarAssert> {
protected UIElement message;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если message это элемент с текстом, то это должен быть не UIElement

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Заменил на public String messageText(), конструктор убрал вообще

protected String messageLocator = "./span";
protected String messageLocator = "//*[@matsnackbarlabel]";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стиль mdc-snackbar__label гораздо более понятнее смотрится

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пофиксил. Теперь так protected String messageLocator = ".mdc-snackbar__label";


protected UIElement action;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это кнопка, а не UIElement

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Заменил protected UIElement action на public Button action;
Модификатор доступа изменил на public так как action после правок используется в SnackbarTests

protected String actionLocator = ".//button";
Expand All @@ -26,7 +26,7 @@ public Snackbar() {

@JDIAction("Get '{name}' message")
public String getMessageText() {
return message.getValue();
return message.getText();
}

@JDIAction("Get '{name}' action")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и ниже все методы тоже требуют переименования

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переименовал getMessageText() в messageText() и getActionText() в actionText()

Expand Down