Skip to content

Commit

Permalink
4911-refactoringRadioButtonTests
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Oct 2, 2023
1 parent b177fd6 commit 2ccdd5a
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.com.pages.ButtonsPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RadioButtonPage;

@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
public class StaticSite {
Expand All @@ -25,4 +26,7 @@ public class StaticSite {

@Url("badges")
public static BadgePage badgePage;

@Url("radio_button")
public static RadioButtonPage radioButtonPage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class AngularPage extends WebPage {
@UI("#bottom-sheet")
public static BottomSheet bottomSheet;
public static Dialog dialog;
public static RadioButtonSection radioButtonSection;
public static CheckboxSection checkboxSection;
public static ToolbarSection toolbarSection;
public static SlideToggleSection slideToggleSection;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.github.com.pages;

import com.epam.jdi.light.angular.elements.common.Button;
import com.epam.jdi.light.angular.elements.complex.RadioButtons;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
import com.epam.jdi.light.ui.html.elements.common.Text;

public class RadioButtonPage extends NewAngularPage{

@UI("(//*[@id='basic-radio-group'])[1]")
public static RadioButtons basicRadioGroup;

@UI("#season-radio-group")
public static RadioButtons seasonRadioGroup;

@UI("#favorite-season-winter")
public static Button winterRadioButton;

@UI("#your-favorite-season-text")
public static Text yourFavoriteSeasonText;

@UI("#basic-radio-group-label-position")
public static RadioButtons labelPositionRadioGroup;

@UI("#basic-radio-group-disabled")
public static RadioButtons disabledRadioGroup;

@UI("(//*[@role='radiogroup'])[8]")
public static RadioButtons requiredRadioGroup;

@UI("#basic-radio-group-ripple-disabled")
public static RadioButtons rippleDisabledRadioGroup;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import org.testng.annotations.Test;

import static com.jdiai.tools.StringUtils.format;
import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.sections.RadioButtonSection.*;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.radioButtonPage;
import static io.github.com.pages.RadioButtonPage.*;

// TODO Move to the new page
@Ignore
public class RadioButtonTests extends TestsInit {
private static final String SPRING = "Spring";
private static final String SUMMER = "Summer";
Expand All @@ -20,12 +18,14 @@ public class RadioButtonTests extends TestsInit {

@BeforeMethod
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
radioButtonPage.open();
waitCondition(() -> radioButtonPage.isOpened());
radioButtonPage.checkOpened();
}

@Test
@Test(description = "Test verifies value and the radio-button is checked")
public void basicRadioButtonsTest() {
basicRadioGroup.show();
basicRadioGroup.is().displayed();
basicRadioGroup.click("2");
basicRadioGroup.click("1");
Expand All @@ -37,7 +37,9 @@ public void basicRadioButtonsTest() {

@Test
public void seasonsRadioButtonsTest() {
seasonRadioGroup.show();
seasonRadioGroup.is().displayed();
winterRadioButton.click();
seasonRadioGroup.click(SUMMER);
seasonRadioGroup.click(WINTER);
seasonRadioGroup.click(AUTUMN);
Expand All @@ -50,5 +52,32 @@ public void seasonsRadioButtonsTest() {
seasonRadioGroup.is().notChecked(SUMMER);
seasonRadioGroup.is().notChecked(AUTUMN);
}
}

@Test(description = "Test verifies that radio-button label in in before position")
public void labelInBeforePosition() {
labelPositionRadioGroup.is().isBeforePosition();
}

@Test(description = "Test verifies that radio-button group is disabled")
public void radioGroupDisabled() {
disabledRadioGroup.is().isDisabled();
}

@Test(description = "Test verifies that radio-button group is required")
public void radioGroupRequired() {
requiredRadioGroup.is().isRequired();
}

@Test(description = "Test verifies radio-button ripple effect")
public void rippleEffect() {
rippleDisabledRadioGroup.is().hasNoRippleEffect("1");
basicRadioGroup.is().hasRippleEffect("1");
}

@Test(description = "Test verifies radio-button aria-label")
public void hasAriaLabel() {
String ARIALABEL = "Select an option";
basicRadioGroup.is().hasAriaLabel(ARIALABEL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,54 @@ public class RadioButtonsAssert extends UIAssert<RadioButtonsAssert, RadioButton

@JDIAction("'{name}' is checked when '{0}' radio button value is provided")
public RadioButtonsAssert checked(String value) {
jdiAssert(element().isChecked(value), Matchers.is(true));
jdiAssert(element().isChecked(value), Matchers.is(true), "Radio button is not checked");
return this;
}

@JDIAction("'{name}' is not checked when '{0}' radio button value is provided")
public RadioButtonsAssert notChecked(String value) {
jdiAssert(element().isChecked(value), Matchers.is(false));
jdiAssert(element().isChecked(value), Matchers.is(false), "Radio button is checked");
return this;
}

@JDIAction("'{name}' label is in before position")
public RadioButtonsAssert isBeforePosition() {
jdiAssert(element().isBeforePosition(), Matchers.is(true),
"Radio button label is not in before position");
return this;
}
@JDIAction("'{name}' is disabled")
public RadioButtonsAssert isDisabled() {
jdiAssert(element().isDisabled(), Matchers.is(true),
"Radio button group is not disabled");
return this;
}

@JDIAction("'{name}' is disabled")
public RadioButtonsAssert isRequired() {
jdiAssert(element().isRequired(), Matchers.is(true),
"Radio button group is not required");
return this;
}

@JDIAction("'{name}' has no ripple effect")
public RadioButtonsAssert hasNoRippleEffect(String value) {
jdiAssert(element().hasNoRippleEffect(value), Matchers.is(true),
"Radio button has ripple effect");
return this;
}

@JDIAction("'{name}' has ripple effect")
public RadioButtonsAssert hasRippleEffect(String value) {
jdiAssert(element().hasNoRippleEffect(value), Matchers.is(false),
"Radio button has no ripple effect");
return this;
}

@JDIAction("'{name}' has aria-label '{0}'")
public RadioButtonsAssert hasAriaLabel(String ariaLabel) {
jdiAssert(element().isAriaLabel(ariaLabel), Matchers.is(true),
"Radio button aria-label is not equal " + ariaLabel);
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public void click(String value) {
getRadioButtonByTagValue(value).click();
}

@JDIAction("'name' has no ripple effect")
public boolean hasNoRippleEffect(String value) {
return getRadioButtonByTagValue(value).attr("disableripple").equalsIgnoreCase("true");
}
@JDIAction("'{name}' radio button contain value '{0}'")
public boolean isChecked(String value) {
return getRadioButtonByTagValue(value).attr("class").contains("mat-radio-checked");
return getRadioButtonByTagValue(value).attr("class").contains("mat-mdc-radio-checked");
}

private UIElement getRadioButtonByTagValue(String value) {
Expand All @@ -32,6 +36,25 @@ private UIElement getRadioButtonByTagValue(String value) {
return element;
}

@JDIAction("'{name}'label is in before position")
public boolean isBeforePosition() {
return core().attr("labelposition").equalsIgnoreCase("before");
}

@JDIAction("'{name}'aria-label is '{0}'")
public boolean isAriaLabel(String ariaLabel) {
return core().attr("aria-label").equalsIgnoreCase(ariaLabel);
}
@JDIAction("'{name}'is disabled")
public boolean isDisabled() {
return core().hasAttribute("disabled");
}

@JDIAction("'{name}'is required")
public boolean isRequired() {
return core().hasAttribute("required");
}

@Override
public RadioButtonsAssert is() {
return new RadioButtonsAssert().set(this);
Expand Down

0 comments on commit 2ccdd5a

Please sign in to comment.