From 95403e47422872edb6a0bdbe3bc81ed65dcfc085 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Sun, 14 Apr 2024 11:07:32 -0500 Subject: [PATCH 1/3] #5336 add area-label to index (if text is empty) --- .../java/io/github/com/pages/displaydata/BadgePage.java | 9 +++------ .../epam/material/tests/displaydata/BadgeTests.java | 7 +++---- .../light/material/asserts/inputs/ButtonGroupAssert.java | 4 ++-- .../jdi/light/material/elements/feedback/Dialog.java | 2 +- .../jdi/light/material/elements/inputs/ButtonGroup.java | 8 ++++++-- 5 files changed, 15 insertions(+), 15 deletions(-) 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..f12d5807aa 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,6 +3,7 @@ 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; @@ -18,12 +19,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/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..cf7801c39a 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,8 @@ 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 com.jdiai.tools.func.JFunc1; + import java.util.List; import java.util.stream.Collectors; @@ -20,7 +22,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 +56,7 @@ public Button button(String text) { * @return all buttons of this button group as {@link List} */ @JDIAction("Get all buttons in '{name}'") - public List