diff --git a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/displaydata/BadgePage.java b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/displaydata/BadgePage.java index 34df057aca..78098dca3f 100644 --- a/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/displaydata/BadgePage.java +++ b/jdi-light-material-ui-tests/src/main/java/io/github/com/pages/displaydata/BadgePage.java @@ -3,8 +3,8 @@ 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.displaydata.Badge; +import com.epam.jdi.light.material.elements.inputs.ButtonGroup; import com.epam.jdi.light.material.elements.inputs.Switch; -import com.epam.jdi.light.ui.html.elements.common.Button; import java.util.List; @@ -18,12 +18,8 @@ public class BadgePage extends WebPage { @UI("#secondaryColorBadge") public static Badge secondaryColorBadgeContainer; - // @todo #5297 Button should be used from ButtomGruop, not directly as single - @UI(".MuiButtonGroup-root button[aria-label='reduce']") - public static Button buttonReduce; - - @UI(".MuiButtonGroup-root button[aria-label='increase']") - public static Button buttonIncrease; + @UI(".MuiButtonGroup-root") + public static ButtonGroup buttons; @UI("//span[text()='Show Zero']/preceding-sibling::span[contains(@class,'MuiSwitch-root')]") public static Switch switchShowZero; diff --git a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/displaydata/BadgeTests.java b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/displaydata/BadgeTests.java index d87e8f327d..1435884c7f 100644 --- a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/displaydata/BadgeTests.java +++ b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/displaydata/BadgeTests.java @@ -9,8 +9,7 @@ import static com.epam.jdi.light.material.elements.utils.enums.Position.TOP_RIGHT; import static io.github.com.StaticSite.badgePage; import static io.github.com.pages.displaydata.BadgePage.badgeDifferentPosition; -import static io.github.com.pages.displaydata.BadgePage.buttonIncrease; -import static io.github.com.pages.displaydata.BadgePage.buttonReduce; +import static io.github.com.pages.displaydata.BadgePage.buttons; import static io.github.com.pages.displaydata.BadgePage.dotBadgeContainer; import static io.github.com.pages.displaydata.BadgePage.secondaryColorBadgeContainer; import static io.github.com.pages.displaydata.BadgePage.switchShowBadge; @@ -31,7 +30,7 @@ public void variousBadgeTest() { .and().has().text(Matchers.equalTo("1")) .and().has().position(TOP_RIGHT.toString()); - buttonReduce.click(); + buttons.button("reduce").click(); secondaryColorBadgeContainer .has().text(Matchers.equalTo("0")) .and().is().notVisible(); @@ -46,7 +45,7 @@ public void variousBadgeTest() { public void maxValueTest() { for (int i = 1; i <= 10; i++) { secondaryColorBadgeContainer.has().text(Matchers.equalTo(String.valueOf(i))); - buttonIncrease.click(); + buttons.button("increase").click(); } secondaryColorBadgeContainer.has().text(Matchers.equalTo("10+")); } diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java index 1fbb57dbcb..530bc53b55 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java @@ -23,7 +23,7 @@ public class ButtonGroupAssert extends UISelectAssert> condition) { - jdiAssert(element().getAllButtons().stream().map(Button::getText).collect(Collectors.toList()), + jdiAssert(element().buttons().stream().map(Button::getText).collect(Collectors.toList()), condition); return this; } diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/displaydata/Badge.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/displaydata/Badge.java index 109ceca653..2245121f1d 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/displaydata/Badge.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/displaydata/Badge.java @@ -18,7 +18,7 @@ public class Badge extends UIBaseElement implements IsText, HasPosition, HasIcon { public static final String MUI_BADGE_DOT_LOCATOR = ".MuiBadge-dot"; - + // @todo #5336 Create a basi class for badge (content or dot) to check style and content @JDIAction("Get '{name}'s dot element") public UIElement dot() { return core().findFirst(MUI_BADGE_DOT_LOCATOR); diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java index 9e57bd4536..58c2c127c6 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java @@ -147,7 +147,7 @@ public void close() { */ @JDIAction("Click '{0}' button on '{name}'") public void clickButton(String buttonName) { - actionButtons().getAllButtons().stream() + actionButtons().buttons().stream() .filter(button -> button.getValue().equalsIgnoreCase(buttonName)) .findFirst() .orElseThrow(() -> runtimeException(String.format("Close button %s not found", buttonName))) diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/inputs/ButtonGroup.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/inputs/ButtonGroup.java index 331f69edc8..b45c735151 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/inputs/ButtonGroup.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/inputs/ButtonGroup.java @@ -7,6 +7,7 @@ import com.epam.jdi.light.elements.complex.WebList; import com.epam.jdi.light.material.asserts.inputs.ButtonGroupAssert; import com.epam.jdi.light.ui.html.elements.common.Button; + import java.util.List; import java.util.stream.Collectors; @@ -20,7 +21,9 @@ public class ButtonGroup extends UIListBase { @Override public WebList list() { - WebList webList = new WebList(core().find(".//button")).setup(JDIBase::searchVisible); + WebList webList = new WebList(core().find("button")) + .setup(JDIBase::searchVisible) + .setUIElementName(ui -> ui.text().isBlank() ? ui.attr("aria-label") : ui.text()); webList.setStartIndex(getStartIndex()); return webList; } @@ -52,7 +55,7 @@ public Button button(String text) { * @return all buttons of this button group as {@link List} */ @JDIAction("Get all buttons in '{name}'") - public List