Skip to content

Commit 0318c2d

Browse files
committed
Fix RadioButton and colors
1 parent 86d62dd commit 0318c2d

File tree

14 files changed

+142
-141
lines changed

14 files changed

+142
-141
lines changed

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,14 @@ public void before() {
4646

4747
@Test(description = "Test checks basic buttons attributes")
4848
public void basicButtonsTest() {
49-
Button basicButton = basicButtons.get(rand.nextInt(basicButtons.size()) + 1);
49+
Button basicButton = basicButtons.get(4);
5050
basicButton.is().displayed();
5151
basicButton.show();
5252
basicButton.is().visible();
5353

5454
basicButton.has().visualType(BASIC);
5555

56-
if (basicButton.isEnabled()) {
57-
basicButton.click();
58-
basicButton.is().focused();
59-
basicbuttonLabel.has().text(containsString(basicButton.text()));
60-
} else {
61-
basicButton.is().disabled();
62-
}
56+
basicButton.has().text("Disabled").is().disabled();
6357
}
6458

6559
@Test(description = "Test checks default color button attributes")
@@ -151,6 +145,6 @@ public void colorButtonsTest() {
151145
accentColorButtons.get(rand.nextInt(accentColorButtons.size()) + 1)
152146
.has().color(AngularColors.ACCENT);
153147
warnColorButtons.get(rand.nextInt(warnColorButtons.size()) + 1)
154-
.has().color(AngularColors.WARN.getColor());
148+
.has().color(AngularColors.WARN.getStyle());
155149
}
156150
}

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void checkLabelValueTest() {
3838
@Test(description = "Test verifies initial checkbox state and selection")
3939
public void basicCheckboxValidationTest() {
4040
basicCheckbox.show();
41-
basicCheckbox.is().displayed().and().enabled().and().deselected();
41+
basicCheckbox.is().displayed().and().enabled().and().notSelected();
4242
basicCheckbox.check();
4343
basicCheckbox.is().selected();
4444
basicCheckbox.uncheck();
@@ -72,6 +72,7 @@ public void alignPositionsCheckboxTest() {
7272
@Test(description = "Test verifies checkbox feature: required option")
7373
public void isRequiredCheckboxTest() {
7474
requiredCheckbox.show();
75+
requiredCheckbox.uncheck();
7576
requiredCheckbox.is().required();
7677
requiredCheckboxText.has().text("Checkbox should be checked!");
7778
requiredCheckbox.check();
@@ -84,21 +85,17 @@ public void isRequiredCheckboxTest() {
8485
@Test(description = "Verifies checkbox colors as Angular colors")
8586
public void angularColorCheckBoxTest() {
8687
//Check color for checkboxes with attribute 'color'
87-
primaryColorCheckbox.has().angularColor(AngularColors.PRIMARY);
88-
accentColorCheckbox.has().angularColor(AngularColors.ACCENT);
89-
warnColorCheckbox.has().angularColor(AngularColors.WARN);
90-
//Check color for checkbox without attribute 'color'
91-
requiredCheckbox.has().angularColor(AngularColors.ACCENT);
92-
}
93-
94-
@Test(description = "Verifies checkbox colors as strings")
95-
public void colorCheckBoxTest() {
96-
//Check color for checkboxes with attribute 'color'
97-
primaryColorCheckbox.has().color("primary");
98-
accentColorCheckbox.has().color("accent");
99-
warnColorCheckbox.has().color("warn");
88+
primaryColorCheckbox.uncheck();
89+
primaryColorCheckbox.has().color(AngularColors.UNSELECTED);
90+
primaryColorCheckbox.check();
91+
primaryColorCheckbox.has().color(AngularColors.PRIMARY);
92+
accentColorCheckbox.check();
93+
accentColorCheckbox.has().color(AngularColors.ACCENT);
94+
warnColorCheckbox.check();
95+
warnColorCheckbox.has().color(AngularColors.WARN);
10096
//Check color for checkbox without attribute 'color'
101-
requiredCheckbox.has().color("accent");
97+
requiredCheckbox.check();
98+
requiredCheckbox.has().color(AngularColors.ACCENT);
10299
}
103100

104101
}

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@
44
import org.testng.annotations.BeforeClass;
55
import org.testng.annotations.Test;
66

7-
import static com.epam.jdi.light.angular.elements.enums.AngularColors.PRIMARY;
8-
import static com.epam.jdi.light.angular.elements.enums.AngularColors.UNDEFINED;
9-
import static com.epam.jdi.light.angular.elements.enums.AngularColors.WARN;
10-
import static com.epam.jdi.light.angular.elements.enums.AngularColors.ACCENT;
7+
import static com.epam.jdi.light.angular.elements.enums.AngularColors.*;
118
import static com.jdiai.tools.Timer.waitCondition;
129
import static io.github.com.StaticSite.radioButtonPage;
1310
import static io.github.com.pages.RadioButtonPage.*;
14-
import static java.lang.String.format;
1511

1612
public class RadioButtonTests extends TestsInit {
17-
private static final String SPRING = "Spring";
18-
private static final String SUMMER = "Summer";
19-
private static final String AUTUMN = "Autumn";
20-
private static final String WINTER = "Winter";
21-
2213
@BeforeClass
2314
public void before() {
2415
radioButtonPage.open();
@@ -31,31 +22,14 @@ public void basicRadioButtonsTest() {
3122
basicRadioGroup.show();
3223
basicRadioGroup.is().displayed();
3324
basicRadioGroup.click("2");
34-
basicRadioGroup.click("1");
35-
basicRadioGroup.click("2");
3625
basicRadioGroup.is().checked("2");
37-
basicRadioGroup.is().notChecked("1");
26+
basicRadioGroup.click("1");
27+
basicRadioGroup.is().checked("1");
28+
basicRadioGroup.is().notChecked("2");
3829
basicRadioGroup.radioButtons().get(1).is().checked();
3930
basicRadioGroup.radioButtons().get(0).is().notChecked();
4031
}
4132

42-
@Test(description = "Test verifies radio group with ngModel functionality")
43-
public void ngModelFunctionalityTest() {
44-
seasonRadioGroup.show();
45-
seasonRadioGroup.is().displayed();
46-
seasonRadioGroup.click(WINTER);
47-
seasonRadioGroup.is().checked(WINTER);
48-
yourFavoriteSeasonText.has().text(format("Your favorite season is: %s", WINTER));
49-
50-
seasonRadioGroup.click(SPRING);
51-
seasonRadioGroup.is().checked(SPRING);
52-
yourFavoriteSeasonText.has().text(format("Your favorite season is: %s", SPRING));
53-
54-
seasonRadioGroup.is().notChecked(WINTER);
55-
seasonRadioGroup.is().notChecked(SUMMER);
56-
seasonRadioGroup.is().notChecked(AUTUMN);
57-
}
58-
5933
@Test(description = "Test verifies that radio-group label in in before/after position")
6034
public void labelGroupPositionTest() {
6135
labelPositionRadioGroup.is().groupBeforePosition();
@@ -64,10 +38,10 @@ public void labelGroupPositionTest() {
6438

6539
@Test(description = "Test verifies that radio-button label in in before/after position")
6640
public void labelRadioButtonPositionTest() {
67-
elementPositionRadioGroup.radioButtons().get(0).has().radioButtonBeforePosition();
68-
basicRadioGroup.radioButtons().get(0).has().radioButtonAfterPosition();
69-
beforePositionRadioGroup.radioButtons().get(0).has().radioButtonBeforePosition();
70-
beforePositionRadioGroup.radioButtons().get(1).has().radioButtonBeforePosition();
41+
elementPositionRadioGroup.radioButtons().get(0).has().labelBeforePosition();
42+
basicRadioGroup.radioButtons().get(0).has().labelAfterPosition();
43+
beforePositionRadioGroup.radioButtons().get(0).has().labelBeforePosition();
44+
beforePositionRadioGroup.radioButtons().get(1).has().labelBeforePosition();
7145
}
7246

7347
@Test(description = "Test verifies radio button label")
@@ -90,8 +64,7 @@ public void radioButtonDisabledTest() {
9064
@Test(description = "Test verifies that radio-button group is required/not required")
9165
public void radioGroupRequiredTest() {
9266
requiredRadioGroup.show();
93-
requiredRadioGroup.is().displayed();
94-
requiredRadioGroup.is().required();
67+
requiredRadioGroup.is().displayed().and().required();
9568
basicRadioGroup.is().notRequired();
9669
}
9770

@@ -107,12 +80,12 @@ public void colorButtonsTest() {
10780
colorRadioGroup.is().displayed();
10881
primaryRadioButton.click();
10982
primaryRadioButton.has().color(PRIMARY);
110-
accentRadioButton.has().color(UNDEFINED);
83+
accentRadioButton.has().color(UNSELECTED);
11184
warnRadioButton.click();
11285
warnRadioButton.has().color(WARN);
113-
primaryRadioButton.has().color(UNDEFINED);
86+
primaryRadioButton.has().color(UNSELECTED);
11487
accentRadioButton.click();
11588
accentRadioButton.has().color(ACCENT);
116-
warnRadioButton.has().color(UNDEFINED);
11789
}
90+
11891
}

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TestsSelectBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected void pickDisableSelectCheckboxAsUnchecked() {
8484
if (disableCheckboxSelect.isSelected() && disableCheckboxSelect.isVisible()) {
8585
disableCheckboxSelect.uncheck();
8686
}
87-
disableCheckboxSelect.is().deselected();
87+
disableCheckboxSelect.is().notSelected();
8888
}
8989

9090
protected void pickDisableSelectCheckboxAsChecked() {

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public ButtonAssert focused() {
2828

2929
@JDIAction("Assert that '{name}' color is '{0}'")
3030
public ButtonAssert color(String expectedColor) {
31-
jdiAssert(element().color().getColor(), Matchers.equalToIgnoringCase(expectedColor.toLowerCase()));
31+
jdiAssert(element().color(), Matchers.equalToIgnoringCase(expectedColor.toLowerCase()));
3232
return this;
3333
}
3434

3535
@JDIAction("Assert that '{name}' color is '{0}'")
3636
public ButtonAssert color(AngularColors expectedColor) {
37-
jdiAssert(element().color().getColor(), Matchers.is(expectedColor.getColor()));
37+
jdiAssert(element().color(), Matchers.is(expectedColor.getColor()));
3838
return this;
3939
}
4040

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public CheckboxAssert selected() {
1616
}
1717

1818
@JDIAction("Assert that '{name}' is not selected")
19-
public CheckboxAssert deselected() {
19+
public CheckboxAssert notSelected() {
2020
jdiAssert(element().isSelected(), Matchers.is(false), "Checkbox is selected");
2121
return this;
2222
}
@@ -72,14 +72,14 @@ public CheckboxAssert notRequired() {
7272
}
7373

7474
@JDIAction("Assert that '{name}' angular color is '{0}'")
75-
public CheckboxAssert angularColor(AngularColors expectedColor) {
76-
jdiAssert(element().color(), Matchers.is(expectedColor));
75+
public CheckboxAssert color(AngularColors expectedColor) {
76+
jdiAssert(element().color(), Matchers.is(expectedColor.getColor()));
7777
return this;
7878
}
7979

8080
@JDIAction("Assert that '{name}' color is '{0}'")
8181
public CheckboxAssert color(String expectedColor) {
82-
jdiAssert(element().color().getColor(), Matchers.is(expectedColor));
82+
jdiAssert(element().color(), Matchers.is(expectedColor));
8383
return this;
8484
}
8585

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioButtonAssert.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,26 @@ public RadioButtonAssert enabled() {
2626

2727
@JDIAction("Assert that '{name}' color is '{0}'")
2828
public RadioButtonAssert color(AngularColors expectedColor) {
29-
jdiAssert(element().color().getColor(), Matchers.is(expectedColor.getColor()));
29+
jdiAssert(AngularColors.fromColor(element().color()), Matchers.is(expectedColor));
30+
return this;
31+
}
32+
33+
@JDIAction("Assert that '{name}' color is '{0}'")
34+
public RadioButtonAssert color(String expectedColor) {
35+
jdiAssert(element().color(), Matchers.is(expectedColor));
3036
return this;
3137
}
3238

3339
@JDIAction("'{name}' element label is in before position")
34-
public RadioButtonAssert radioButtonBeforePosition() {
35-
jdiAssert(element().hasBeforePosition(), Matchers.is(true),
40+
public RadioButtonAssert labelBeforePosition() {
41+
jdiAssert(element().hasLabelBeforePosition(), Matchers.is(true),
3642
"Radio button label is not in before position");
3743
return this;
3844
}
3945

4046
@JDIAction("'{name}' element label is in before position")
41-
public RadioButtonAssert radioButtonAfterPosition() {
42-
jdiAssert(element().hasBeforePosition(), Matchers.is(false),
47+
public RadioButtonAssert labelAfterPosition() {
48+
jdiAssert(element().hasLabelBeforePosition(), Matchers.is(false),
4349
"Radio button label is not in after position");
4450
return this;
4551
}
@@ -61,7 +67,4 @@ public RadioButtonAssert label(String value) {
6167
jdiAssert(element().label().getValue(), Matchers.is(value));
6268
return this;
6369
}
64-
65-
66-
6770
}

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioGroupAssert.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public RadioGroupAssert notChecked(String value) {
2323

2424
@JDIAction("'{name}' label is in before position")
2525
public RadioGroupAssert groupBeforePosition() {
26-
jdiAssert(element().isGroupBeforePosition(), Matchers.is(true),
26+
jdiAssert(element().isLabelsBeforePosition(), Matchers.is(true),
2727
"Radio group label is not in before position");
2828
return this;
2929
}
3030

3131
@JDIAction("'{name}' label is in after position")
3232
public RadioGroupAssert groupAfterPosition() {
33-
jdiAssert(element().isGroupBeforePosition(), Matchers.is(false),
33+
jdiAssert(element().isLabelsBeforePosition(), Matchers.is(false),
3434
"Radio group label is not in after position");
3535
return this;
3636
}
@@ -66,14 +66,14 @@ public RadioGroupAssert notRequired() {
6666

6767
@JDIAction("'{name}' has checked radio button")
6868
public RadioGroupAssert checkedRadioButton() {
69-
jdiAssert(element().getCheckedRadioButton(), Matchers.notNullValue(),
69+
jdiAssert(element().checkedRadioButton(), Matchers.notNullValue(),
7070
"There is no checked radio button in the group");
7171
return this;
7272
}
7373

7474
@JDIAction("'{name}' has no checked radio button")
7575
public RadioGroupAssert noCheckedRadioButton() {
76-
jdiAssert(element().getCheckedRadioButton(), Matchers.nullValue(),
76+
jdiAssert(element().checkedRadioButton(), Matchers.nullValue(),
7777
"There is checked radio button in the group");
7878
return this;
7979
}

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,30 @@
1313
public class Button extends UIBaseElement<ButtonAssert> implements HasBadge, HasClick, IsText {
1414

1515
private static final String ICON_LOCATOR = ".//mat-icon";
16+
private static final String LABEL_LOCATOR = ".mdc-button__label";
1617

1718
@JDIAction(value = "Get if '{name}' is focused")
1819
public boolean focused() {
1920
return hasClass("cdk-focused");
2021
}
2122

22-
@JDIAction(value = "Get '{name}' color")
23-
public AngularColors color() {
24-
return AngularColors.fromColor(core().getAttribute("color"));
23+
@JDIAction("Get '{name}' color")
24+
public String color() {
25+
return core().getCssValue("background-color");
2526
}
2627

27-
@JDIAction(value = "Get if '{name}' has default color")
28+
@JDIAction("Get if '{name}' has default color")
2829
public boolean defaultColor() {
2930
return attrs().has("defaultcolor");
3031
}
3132

32-
@JDIAction(value = "Get visual type '{name}'")
33+
@Override
34+
@JDIAction("Get '{name}' text")
35+
public String getText() {
36+
return core().find(LABEL_LOCATOR).text();
37+
}
38+
39+
@JDIAction("Get visual type '{name}'")
3340
public ButtonsTypes visualType() {
3441
MapArray<String, String> attrsMap = this.attrs();
3542
for (int i = 0; i < ButtonsTypes.size(); i++) {

0 commit comments

Comments
 (0)