Skip to content

Commit

Permalink
4911_radioButtonsTestsRefactResolveConflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Nov 14, 2023
1 parent 59c4242 commit b6e5d92
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 14 deletions.
1 change: 0 additions & 1 deletion config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<suppress checks="JavadocStyle" files=".*.java"/>

<!-- Minor, useless, not definite rules -->
<suppress checks="NewlineAtEndOfFile" files=".*.java"/>
<suppress checks="NeedBraces" files=".*.java"/>
<suppress checks="ParameterName" files=".*.java"/>
<suppress checks="ReturnCount" files=".*.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public class ChipsSection extends Section {
@UI("#mat-chip-list-3")
public static Chips chipsWithInputList;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public class SliderSection extends Section {
public static Checkbox sliderConfigurableVertical;
public static Checkbox sliderConfigurableInvert;
public static Checkbox sliderConfigurableDisabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
public class SortingOverviewSection extends Section {
@UI("#sort-headers tr:nth-child(1)")
public static SortingOverview sortingOverview;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.testng.annotations.Test;

import static com.epam.jdi.light.angular.elements.enums.AngularColors.PRIMARY;
import static com.epam.jdi.light.angular.elements.enums.AngularColors.UNDEFINED;
import static com.epam.jdi.light.angular.elements.enums.AngularColors.WARN;
import static com.epam.jdi.light.angular.elements.enums.AngularColors.ACCENT;
import static com.jdiai.tools.Timer.waitCondition;
Expand Down Expand Up @@ -34,6 +35,8 @@ public void basicRadioButtonsTest() {
basicRadioGroup.click("2");
basicRadioGroup.is().checked("2");
basicRadioGroup.is().notChecked("1");
basicRadioGroup.radioButtons().get(1).is().checked();
basicRadioGroup.radioButtons().get(0).is().notChecked();
}

@Test(description = "Test verifies radio group with ngModel functionality")
Expand Down Expand Up @@ -67,6 +70,11 @@ public void labelRadioButtonPositionTest() {
beforePositionRadioGroup.radioButtons().get(1).has().radioButtonBeforePosition();
}

@Test(description = "Test verifies radio button label")
public void radioButtonLabelTest() {
requiredRadioGroup.radioButtons().get(0).has().label("One");
}

@Test(description = "Test verifies that radio-button group is disabled/enabled")
public void radioGroupDisabledTest() {
disabledRadioGroup.is().disabled();
Expand All @@ -87,15 +95,24 @@ public void radioGroupRequiredTest() {
basicRadioGroup.is().notRequired();
}

@Test(description = "Test verifies that there is checked radio-button in the group")
public void getCheckedRadioButtonTest() {
colorRadioGroup.has().checkedRadioButton();
requiredRadioGroup.has().noCheckedRadioButton();
}

@Test(description = "Check radio buttons colors")
public void colorButtonsTest() {
colorRadioGroup.show();
colorRadioGroup.is().displayed();
primaryRadioButton.click();
primaryRadioButton.has().color(PRIMARY);
accentRadioButton.has().color(UNDEFINED);
warnRadioButton.click();
warnRadioButton.has().color(WARN);
primaryRadioButton.has().color(UNDEFINED);
accentRadioButton.click();
accentRadioButton.has().color(ACCENT);
warnRadioButton.has().color(UNDEFINED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,25 @@ public RadioButtonAssert radioButtonAfterPosition() {
"Radio button label is not in after position");
return this;
}

@JDIAction("'{name}' is checked")
public RadioButtonAssert checked() {
jdiAssert(element().isChecked(), Matchers.is(true), "Radio button is not checked");
return this;
}

@JDIAction("'{name}' is not checked")
public RadioButtonAssert notChecked() {
jdiAssert(element().isChecked(), Matchers.is(false), "Radio button is checked");
return this;
}

@JDIAction("'{name}' has label with value '{0}'")
public RadioButtonAssert label(String value) {
jdiAssert(element().label().getValue(), Matchers.is(value));
return this;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ public RadioGroupAssert notRequired() {
"Radio group is required");
return this;
}

@JDIAction("'{name}' has checked radio button")
public RadioGroupAssert checkedRadioButton() {
jdiAssert(element().getCheckedRadioButton(), Matchers.notNullValue(),
"There is no checked radio button in the group");
return this;
}

@JDIAction("'{name}' has no checked radio button")
public RadioGroupAssert noCheckedRadioButton() {
jdiAssert(element().getCheckedRadioButton(), Matchers.nullValue(),
"There is checked radio button in the group");
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.common.Label;
import com.epam.jdi.light.elements.interfaces.base.HasLabel;
import org.openqa.selenium.By;

public class RadioButton extends UIBaseElement<RadioButtonAssert> implements HasLabel {
private static final String INPUT_SELECTION_CONTROL = ".//input[@type='radio']";
private static final String LABEL_LOCATOR = "//label";
private static final String FORM_FIELD_LOCATOR = ".mdc-form-field";

@Override
public RadioButtonAssert is() {
Expand All @@ -28,23 +28,26 @@ public boolean isDisabled() {

@JDIAction("Get '{name}' input control color")
public AngularColors color() {
if (hasClass("mat-primary")) {
return AngularColors.PRIMARY;
if (isChecked()) {
if (hasClass("mat-primary")) {
return AngularColors.PRIMARY;
}
if (hasClass("mat-warn")) {
return AngularColors.WARN;
} else
return AngularColors.ACCENT;
}
if (hasClass("mat-warn")) {
return AngularColors.WARN;
} else
return AngularColors.ACCENT;
return AngularColors.UNDEFINED;
}

@JDIAction("'{name}' element label is in before position")
public boolean hasBeforePosition() {
return core().find(By.className("mdc-form-field")).hasClass("mdc-form-field--align-end");
return core().find(FORM_FIELD_LOCATOR).hasClass("mdc-form-field--align-end");
}

@JDIAction("Click '{name}' radio button")
public void click() {
find(By.cssSelector(".mdc-form-field")).click();
find(FORM_FIELD_LOCATOR).click();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public RadioButton getRadioButtonByValue(String value) {
public RadioButton getCheckedRadioButton() {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.hasClass("mat-mdc-radio-checked")) {
if (e.isChecked()) {
radioButton = e;
}
}
Expand Down

0 comments on commit b6e5d92

Please sign in to comment.