diff --git a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/navigation/ContextMenuPage.java b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/navigation/ContextMenuPage.java index affd3f0dbc..5ceea4ed58 100644 --- a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/navigation/ContextMenuPage.java +++ b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/navigation/ContextMenuPage.java @@ -1,8 +1,8 @@ package io.github.com.pages.navigation; -import com.epam.jdi.light.elements.complex.Menu; import com.epam.jdi.light.elements.composite.WebPage; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; +import com.epam.jdi.light.material.elements.navigation.Menu; import com.epam.jdi.light.ui.html.elements.common.Text; public class ContextMenuPage extends WebPage { @@ -10,7 +10,6 @@ public class ContextMenuPage extends WebPage { @UI("p.MuiTypography-root") public static Text pageText; - // @todo #5297 Check the locator, looks like it points to item, not for Menu - @UI(".MuiMenuItem-root") + @UI(".MuiMenu-list") public static Menu contextMenuList; } diff --git a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/surfaces/SimpleAppBarPage.java b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/surfaces/SimpleAppBarPage.java index f043b4ca92..034e75dbb7 100644 --- a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/surfaces/SimpleAppBarPage.java +++ b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/surfaces/SimpleAppBarPage.java @@ -1,9 +1,9 @@ package io.github.com.pages.surfaces; -import com.epam.jdi.light.elements.complex.Menu; import com.epam.jdi.light.elements.composite.WebPage; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; import com.epam.jdi.light.material.elements.inputs.Switch; +import com.epam.jdi.light.material.elements.navigation.Menu; import com.epam.jdi.light.material.elements.surfaces.AppBar; public class SimpleAppBarPage extends WebPage { @@ -17,7 +17,7 @@ public class SimpleAppBarPage extends WebPage { @UI(".MuiAppBar-root[2]") public static AppBar appBarWithMenu; - @UI(".MuiMenuItem-root") + @UI(".MuiMenu-list") public static Menu appBarMenuItems; @UI(".MuiAppBar-root[3]") diff --git a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/ContextMenuTests.java b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/ContextMenuTests.java new file mode 100644 index 0000000000..05b80867cb --- /dev/null +++ b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/ContextMenuTests.java @@ -0,0 +1,39 @@ +package io.github.epam.material.tests.navigation; + +import com.epam.jdi.light.ui.html.elements.common.Button; +import io.github.epam.TestsInit; +import io.github.epam.test.data.MenuDataProvider; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.List; + +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.contextMenuPage; +import static io.github.com.StaticSite.simpleMenuPage; +import static io.github.com.pages.navigation.ContextMenuPage.contextMenuList; +import static io.github.com.pages.navigation.ContextMenuPage.pageText; +import static io.github.com.pages.navigation.SimpleMenuPage.*; + +public class ContextMenuTests extends TestsInit { + + private static final List CONTEXT_MENU_ITEMS = Arrays.asList("Copy", "Print", "Highlight", "Email"); + + @BeforeMethod + public void before() { + contextMenuPage.open(); + contextMenuPage.isOpened(); + } + + @Test + public void contextMenuTest() { + pageText.is().displayed(); + + pageText.rightClick(); + menu.is().displayed().and().has().itemsTexts(CONTEXT_MENU_ITEMS); + contextMenuList.select("Print"); + waitCondition(() -> menu.isHidden()); + menu.is().hidden(); + } +} diff --git a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/MenuTests.java b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/MenuTests.java index 853dbe36fd..ee7f4574f6 100644 --- a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/MenuTests.java +++ b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/navigation/MenuTests.java @@ -6,14 +6,9 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Arrays; import java.util.List; -import static com.jdiai.tools.Timer.waitCondition; -import static io.github.com.StaticSite.contextMenuPage; import static io.github.com.StaticSite.simpleMenuPage; -import static io.github.com.pages.navigation.ContextMenuPage.contextMenuList; -import static io.github.com.pages.navigation.ContextMenuPage.pageText; import static io.github.com.pages.navigation.SimpleMenuPage.iconMenuButton; import static io.github.com.pages.navigation.SimpleMenuPage.menu; import static io.github.com.pages.navigation.SimpleMenuPage.scrollMenuButton; @@ -26,8 +21,6 @@ public class MenuTests extends TestsInit { - private static final List CONTEXT_MENU_ITEMS = Arrays.asList("Copy", "Print", "Highlight", "Email"); - @BeforeMethod public void before() { simpleMenuPage.open(); @@ -90,17 +83,4 @@ public void scrollMenuTest() { menu.select(option); selectedScrollMenuItem.has().text("Selected menu: " + option); } - - @Test - public void contextMenuTest() { - contextMenuPage.open(); - contextMenuPage.isOpened(); - pageText.is().displayed(); - - pageText.rightClick(); - menu.is().displayed().and().has().itemsTexts(CONTEXT_MENU_ITEMS); - contextMenuList.select("Print"); - waitCondition(() -> menu.isHidden()); - menu.is().hidden(); - } } diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/navigation/Menu.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/navigation/Menu.java index fc592b7186..67d9aa28fa 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/navigation/Menu.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/navigation/Menu.java @@ -68,7 +68,7 @@ public List itemsTexts() { @Override @JDIAction("Get selected '{name}' item") public String selected() { - return list().filter(e -> e.core().hasClass("Mui-selected")).get(0).text(); + return core().find(".Mui-selected").text(); } /** @@ -81,6 +81,10 @@ public void scrollToItem(String menuItemName) { get(menuItemName).core().jsExecute("scrollIntoView()"); } + public boolean isDisplayed() { + return core().isDisplayed(); + } + @Override public MenuAssert is() { return new MenuAssert().set(this);