Skip to content

Commit

Permalink
#5346 Fix Menu usage and MaterialUI Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed Apr 13, 2024
1 parent dc65a3a commit fdaebe2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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 {

@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;
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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]")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,8 +21,6 @@

public class MenuTests extends TestsInit {

private static final List<String> CONTEXT_MENU_ITEMS = Arrays.asList("Copy", "Print", "Highlight", "Email");

@BeforeMethod
public void before() {
simpleMenuPage.open();
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<String> 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();
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit fdaebe2

Please sign in to comment.