Skip to content

Commit

Permalink
Merge pull request #5466 from jdi-testing/5336
Browse files Browse the repository at this point in the history
#5336 add area-label to index (if text is empty)
  • Loading branch information
pnatashap authored Apr 14, 2024
2 parents 9b20345 + db4f4a2 commit f197988
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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+"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ButtonGroupAssert extends UISelectAssert<ButtonGroupAssert, ButtonG
*/
@JDIAction(value = "Assert that '{name}' has '{0}' buttons", isAssert = true)
public ButtonGroupAssert buttons(int number) {
jdiAssert(element().getAllButtons().size(), Matchers.is(number));
jdiAssert(element().buttons().size(), Matchers.is(number));
return this;
}

Expand All @@ -35,7 +35,7 @@ public ButtonGroupAssert buttons(int number) {
*/
@JDIAction(value = "Assert that '{name}' buttons texts '{0}'", isAssert = true)
public ButtonGroupAssert buttonsTexts(Matcher<Iterable<?>> condition) {
jdiAssert(element().getAllButtons().stream().map(Button::getText).collect(Collectors.toList()),
jdiAssert(element().buttons().stream().map(Button::getText).collect(Collectors.toList()),
condition);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class Badge extends UIBaseElement<BadgeAssert> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,7 +21,9 @@ public class ButtonGroup extends UIListBase<ButtonGroupAssert> {

@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;
}
Expand Down Expand Up @@ -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<Button> getAllButtons() {
public List<Button> buttons() {
return list().stream().map(this::castToButton).collect(Collectors.toList());
}

Expand Down

0 comments on commit f197988

Please sign in to comment.