Skip to content

Commit

Permalink
4911-refRadioButtonClassAdded
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Oct 31, 2023
1 parent 5721e73 commit 609725d
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.epam.jdi.light.angular.elements.common.ProgressBar;
import com.epam.jdi.light.angular.elements.common.Slider;
import com.epam.jdi.light.angular.elements.complex.RadioGroup;
import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioGroup;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
import com.epam.jdi.light.ui.html.elements.common.Button;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.com.pages;

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

Expand All @@ -14,13 +14,13 @@ public class RadioButtonPage extends NewAngularPage {
public static RadioGroup seasonRadioGroup;

@UI("#radio-buttons_dialog_color_radio")
public static Button primaryButton;
public static RadioButton primaryRadioButton;

@UI("#radio-buttons_first-tabbable_color_radio")
public static Button accentButton;
public static RadioButton accentRadioButton;

@UI("#radio-buttons_first-heading_color_radio")
public static Button warnButton;
public static RadioButton warnRadioButton;

@UI("(//*[@id='basic-radio-group'])[2]")
public static RadioGroup elementPositionRadioGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.com.pages.sections;

import com.epam.jdi.light.angular.elements.common.Checkbox;
import com.epam.jdi.light.angular.elements.complex.RadioGroup;
import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioGroup;
import com.epam.jdi.light.angular.elements.complex.SideNav;
import com.epam.jdi.light.elements.common.UIElement;
import com.epam.jdi.light.elements.composite.Section;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public class RadioButtonTests extends TestsInit {
private static final String SUMMER = "Summer";
private static final String AUTUMN = "Autumn";
private static final String WINTER = "Winter";
private static final String primary = "primary";
private static final String accent = "accent";
private static final String warn = "warn";

@BeforeClass
public void before() {
Expand All @@ -40,7 +37,7 @@ public void basicRadioButtonsTest() {
}

@Test(description = "Test verifies radio group with ngModel functionality")
public void seasonsRadioButtonsTest() {
public void ngModelFunctionalityTest() {
seasonRadioGroup.show();
seasonRadioGroup.is().displayed();
seasonRadioGroup.click(WINTER);
Expand All @@ -56,36 +53,48 @@ public void seasonsRadioButtonsTest() {
seasonRadioGroup.is().notChecked(AUTUMN);
}

@Test(description = "Test verifies that radio-group label in in before position")
public void labelInBeforePosition() {
labelPositionRadioGroup.is().isGroupBeforePosition();
@Test(description = "Test verifies that radio-group label in in before/after position")
public void labelGroupPositionTest() {
labelPositionRadioGroup.is().groupBeforePosition();
basicRadioGroup.is().groupAfterPosition();
}

@Test(description = "Test verifies that radio-group label in in before position")
public void elementLabelInBeforePosition() {
elementPositionRadioGroup.is().isGroupElementBeforePosition("1");
@Test(description = "Test verifies that radio-button label in in before/after position")
public void labelRadioButtonPositionTest() {
elementPositionRadioGroup.radioButtons().get(0).is().radioButtonBeforePosition();
basicRadioGroup.radioButtons().get(0).is().radioButtonAfterPosition();

}

@Test(description = "Test verifies that radio-button group is disabled/enabled")
public void radioGroupDisabledTest() {
disabledRadioGroup.is().disabled();
basicRadioGroup.is().enabled();
}

@Test(description = "Test verifies that radio-button group is disabled")
public void radioGroupDisabled() {
disabledRadioGroup.is().isDisabled();
@Test(description = "Test verifies that radio-button in group is disabled/enabled")
public void radioButtonDisabledTest() {
disabledRadioGroup.radioButtons().get(0).is().disabled();
basicRadioGroup.radioButtons().get(0).is().enabled();
}

@Test(description = "Test verifies that radio-button group is required")
public void radioGroupRequired() {
@Test(description = "Test verifies that radio-button group is required/not required")
public void radioGroupRequiredTest() {
requiredRadioGroup.show();
requiredRadioGroup.is().visible();
requiredRadioGroup.is().isRequired();
requiredRadioGroup.is().displayed();
requiredRadioGroup.is().required();
basicRadioGroup.is().notRequired();
}

@Test(description = "Check radio buttons colors")
public void colorButtonsTest() {
primaryButton.click();
colorRadioGroup.is().color(PRIMARY, primary);
warnButton.click();
colorRadioGroup.is().color(WARN, warn);
accentButton.click();
colorRadioGroup.is().color(ACCENT, accent);
colorRadioGroup.show();
colorRadioGroup.is().displayed();
primaryRadioButton.click();
primaryRadioButton.has().color(PRIMARY);
warnRadioButton.click();
warnRadioButton.has().color(WARN);
accentRadioButton.click();
accentRadioButton.has().color(ACCENT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.epam.jdi.light.angular.asserts.radiobuttons;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;

import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioButton;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;

public class RadioButtonAssert extends UIAssert<RadioButtonAssert, RadioButton> {

@Override
@JDIAction("Assert that '{name}' is disabled")
public RadioButtonAssert disabled() {
jdiAssert(element().isDisabled(), Matchers.is(true), "Element is enabled");
return this;
}

@Override
@JDIAction("Assert that '{name}' is disabled")
public RadioButtonAssert enabled() {
jdiAssert(element().isDisabled(), Matchers.is(false), "Element is disabled");
return this;
}

@JDIAction("Assert that '{name}' color is '{0}'")
public RadioButtonAssert color(AngularColors expectedColor) {
jdiAssert(element().color().getColor(), Matchers.is(expectedColor.getColor()));
return this;
}

@JDIAction("'{name}' element label is in before position")
public RadioButtonAssert radioButtonBeforePosition() {
jdiAssert(element().isRadioButtonBeforePosition(), Matchers.is(true),
"Radio button label is not in before position");
return this;
}

@JDIAction("'{name}' element label is in before position")
public RadioButtonAssert radioButtonAfterPosition() {
jdiAssert(element().isRadioButtonBeforePosition(), Matchers.is(false),
"Radio button label is not in after position");
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.epam.jdi.light.angular.asserts;
package com.epam.jdi.light.angular.asserts.radiobuttons;

import com.epam.jdi.light.angular.elements.complex.RadioGroup;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioGroup;
import com.epam.jdi.light.asserts.generic.UISelectAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
Expand All @@ -23,37 +22,45 @@ public RadioGroupAssert notChecked(String value) {
}

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

@JDIAction("'{name}' element label is in before position")
public RadioGroupAssert isGroupElementBeforePosition(String value) {
jdiAssert(element().isGroupElementBeforePosition(value), Matchers.is(true),
"Radio button group element label is not in before position");
@JDIAction("'{name}' label is in after position")
public RadioGroupAssert groupAfterPosition() {
jdiAssert(element().isGroupBeforePosition(), Matchers.is(false),
"Radio group label is not in after position");
return this;
}


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

@JDIAction("'{name}' is disabled")
public RadioGroupAssert isRequired() {
@JDIAction("'{name}' is enabled")
public RadioGroupAssert enabled() {
jdiAssert(element().isDisabled(), Matchers.is(false),
"Radio group is disabled");
return this;
}

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

@JDIAction("Assert that '{name}' color is '{0}'")
public RadioGroupAssert color(AngularColors expectedColor, String value) {
jdiAssert(element().color(value).getColor(), Matchers.is(expectedColor.getColor()));
@JDIAction("'{name}' is not required")
public RadioGroupAssert notRequired() {
jdiAssert(element().isRequired(), Matchers.is(false),
"Radio group is required");
return this;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.epam.jdi.light.angular.elements.complex.radiobuttons;

import com.epam.jdi.light.angular.asserts.radiobuttons.RadioButtonAssert;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
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']";

@Override
public RadioButtonAssert is() {
return new RadioButtonAssert().set(this);
}

@Override
public RadioButtonAssert has() { return is(); }

@Override
@JDIAction("Get if '{name}' is disabled")
public boolean isDisabled() {
return find(INPUT_SELECTION_CONTROL).hasAttribute("disabled");
}

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

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

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

0 comments on commit 609725d

Please sign in to comment.