diff --git a/jdi-light-angular-tests/pom.xml b/jdi-light-angular-tests/pom.xml
index c251b0e8ffb..85e0eb2c827 100644
--- a/jdi-light-angular-tests/pom.xml
+++ b/jdi-light-angular-tests/pom.xml
@@ -40,6 +40,12 @@
allure-testng
${allure.testng}
+
+ com.epam.jdi
+ jdi-light-core
+ 1.5.0-SNAPSHOT
+ compile
+
diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java
index c31a21450c5..6361d32900f 100644
--- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java
+++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java
@@ -50,7 +50,6 @@ public class AngularPage extends WebPage {
public static SelectSection selectSection;
public static ListSection listSection;
public static GridListSection gridListSection;
- public static BasicButtonsSection basicButtonsSection;
public static AutocompleteSection autocompleteSection;
public static SnackbarSection snackbarSection;
public static ButtonToggleSection buttonToggleSection;
diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java
index 522f1cb9748..4ed2887d1a1 100644
--- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java
+++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java
@@ -4,8 +4,18 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static com.epam.jdi.light.angular.elements.enums.BadgePosition.ABOVE;
+import static com.epam.jdi.light.angular.elements.enums.BadgePosition.AFTER;
+import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BEFORE;
+import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BELOW;
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE;
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM;
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.badgePage;
+import static io.github.com.enums.Colors.AMBER_ACCENT_2;
+import static io.github.com.enums.Colors.DEEP_PURPLE;
+import static io.github.com.enums.Colors.RED;
import static io.github.com.pages.BadgePage.bellowPositionBadge;
import static io.github.com.pages.BadgePage.buttonWithBadge;
import static io.github.com.pages.BadgePage.customSizeBadge;
@@ -23,50 +33,34 @@ public void before() {
badgePage.open();
waitCondition(() -> badgePage.isOpened());
badgePage.checkOpened();
- }
-
- @Test
- public void basicBadgeTest() {
textWithBadge.show();
- textWithBadge.badge().is().displayed();
- textWithBadge.badge().has().text("4");
- textWithBadge.has().color("Violet");
- }
-
- @Test
- public void buttonBadgeTest() {
- buttonWithBadge.show();
- buttonWithBadge.badge().is().displayed();
- buttonWithBadge.badge().has().text("8");
- buttonWithBadge.has().color("Yellow");
- }
-
- @Test
- public void iconBadgeTest() {
- iconWithBadge.show();
- iconWithBadge.badge().is().displayed();
- iconWithBadge.badge().has().text("15");
- iconWithBadge.has().color("Red");
}
- @Test
- public void badgeWithTextTest() {
- customSizeBadge.badge().is().displayed();
- customSizeBadge.badge().has().text("Best");
- customSizeBadge.has().color("Violet");
-
+ @Test(description = "The test checks color of the badge and content (string/number)")
+ public void colorAndContentBadgeTest() {
+ iconWithBadge.is().displayed()
+ .has().text("15")
+ .and().has().color(RED.value());
+ buttonWithBadge.is().displayed()
+ .has().text("8")
+ .and().has().color(AMBER_ACCENT_2.value());
+ customSizeBadge.is().displayed()
+ .has().text("Best")
+ .and().has().color(DEEP_PURPLE.value());
}
- @Test
+ @Test(description = "Test checks if the badge is disabled/enabled")
public void disabledBadgeTest() {
toggleDisabledBadge.is().disabled();
- toggleVisibilityBadge.click();
- toggleVisibilityBadge.is().enabled();
- toggleVisibilityBadge.click();
+
+ toggleDisabledBadge.click();
+ toggleDisabledBadge.is().enabled();
+
+ toggleDisabledBadge.click();
toggleDisabledBadge.is().disabled();
}
- @Test
+ @Test(description = "Test checks the visibility of the badge")
public void hiddenBadgeTest() {
toggleVisibilityBadge.is().displayed();
toggleVisibilityBadge.click();
@@ -75,33 +69,34 @@ public void hiddenBadgeTest() {
toggleVisibilityBadge.is().displayed();
}
- @Test
+ @Test(description = "Test checks if badge overlaps")
public void overlapBadgeTest() {
textWithBadge.is().overlap(false);
+
buttonWithBadge.is().overlap(true);
}
- @Test
+ @Test(description = "Test check position of the badge")
public void positionOfTheBadgeTest() {
- buttonWithBadge.has().positionVertical("above");
- buttonWithBadge.has().positionHorizontal("before");
+ buttonWithBadge.has().positionVertical(ABOVE)
+ .and().has().positionHorizontal(BEFORE);
- textWithBadge.has().positionVertical("above");
- textWithBadge.has().positionHorizontal("after");
+ textWithBadge.has().positionVertical(ABOVE)
+ .and().has().positionHorizontal(AFTER);
- bellowPositionBadge.has().positionVertical("below");
- bellowPositionBadge.has().positionHorizontal("after");
+ bellowPositionBadge.has().positionVertical(BELOW)
+ .and().has().positionHorizontal(AFTER);
}
- @Test
+ @Test(description = "Test checks size of the badge")
public void sizeOfTheBadgeTest() {
- largeBadge.badge().is().displayed();
- largeBadge.has().size("large");
+ largeBadge.is().displayed()
+ .and().has().size(LARGE);
- smallBadge.badge().is().displayed();
- smallBadge.has().size("small");
+ smallBadge.is().displayed()
+ .and().has().size(SMALL);
- textWithBadge.badge().is().displayed();
- textWithBadge.has().size("medium");
+ textWithBadge.is().displayed()
+ .and().has().size(MEDIUM);
}
}
diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java
index 94b2e257e78..39b6079c4f9 100644
--- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java
+++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java
@@ -5,27 +5,18 @@
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
-import static com.jdiai.tools.Timer.waitCondition;
-import static io.github.com.StaticSite.badgePage;
-import static io.github.com.pages.BadgePage.textWithBadge;
+import static io.github.com.StaticSite.angularPage;
+import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import static org.testng.Assert.assertTrue;
+// TODO Move to the new page
+@Ignore
public class BadgeUnitTests extends TestsInit {
@BeforeMethod(alwaysRun = true)
public void before() {
- badgePage.open();
- waitCondition(() -> badgePage.isOpened());
- badgePage.checkOpened();
+ shouldBeLoggedIn();
+ angularPage.shouldBeOpened();
}
- @Test
- public void badgeTest() {
- assertTrue(textWithBadge.badge().isDisplayed());
- }
-
- @Test
- public void colorTest() {
- assertTrue(textWithBadge.color("Violet"));
- }
}
diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java
index 11640b705a9..2a0cf91382f 100644
--- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java
+++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java
@@ -1,72 +1,79 @@
package com.epam.jdi.light.angular.asserts;
import com.epam.jdi.light.angular.elements.common.Badge;
+import com.epam.jdi.light.angular.elements.enums.BadgePosition;
+import com.epam.jdi.light.angular.elements.enums.BadgeSize;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;
+import static java.lang.String.format;
public class BadgeAssert extends UIAssert {
@JDIAction("Assert that '{name}' has '{0}' color")
public BadgeAssert color(String value) {
- jdiAssert(element().color(value), Matchers.is(true));
+ String actualColor = element().color();
+ jdiAssert(actualColor, Matchers.equalTo(value), format("%s is not equal to %s", actualColor, value));
return this;
}
@JDIAction("Assert that '{name}' has '{0}' size")
- public BadgeAssert size(String value) {
- jdiAssert(element().size(value), Matchers.is(true));
+ public BadgeAssert size(BadgeSize size) {
+ final BadgeSize actualBadgeSize = element().size();
+ jdiAssert(actualBadgeSize, Matchers.is(size), format("%s is not equal to %s", actualBadgeSize, size));
return this;
}
@JDIAction("Assert that '{name}' has '{0}' position (vertical)")
- public BadgeAssert positionVertical(String value) {
- jdiAssert(element().positionVertical(value), Matchers.is(true));
+ public BadgeAssert positionVertical(BadgePosition value) {
+ final BadgePosition actualPosition = element().positionVertical();
+ jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value));
return this;
}
@JDIAction("Assert that '{name}' has '{0}' position (horizontal)")
- public BadgeAssert positionHorizontal(String value) {
- jdiAssert(element().positionHorizontal(value), Matchers.is(true));
+ public BadgeAssert positionHorizontal(BadgePosition value) {
+ final BadgePosition actualPosition = element().positionHorizontal();
+ jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value));
return this;
}
@JDIAction("Assert that '{name}' is overlap: {0}")
public BadgeAssert overlap(boolean value) {
- jdiAssert(element().overlap(), Matchers.is(value));
+ jdiAssert(element().isOverlap(), Matchers.is(value), value ? "should be overlap" : "should NOT be overlap");
return this;
}
@Override
@JDIAction("Assert that '{name}' is displayed")
public BadgeAssert displayed() {
- jdiAssert(element().hidden(), Matchers.is(false));
+ jdiAssert(element().isDisplayed(), Matchers.is(true), "should be displayed");
return super.displayed();
}
- @Override
- @JDIAction("Assert that '{name}' is hidden")
- public BadgeAssert hidden() {
- jdiAssert(element().hidden(), Matchers.is(true));
- return this;
- }
-
@Override
@JDIAction("Assert that '{name}' is enabled")
public BadgeAssert enabled() {
- jdiAssert(element().disabled(), Matchers.is(false));
+ jdiAssert(element().isEnabled(), Matchers.is(true), "should be enabled");
return super.enabled();
}
@Override
@JDIAction("Assert that '{name}' is disabled")
public BadgeAssert disabled() {
- jdiAssert(element().disabled(), Matchers.is(true));
+ jdiAssert(element().isDisabled(), Matchers.is(true), "should be disabled");
+ return this;
+ }
+
+ @JDIAction("Assert that '{name}' has text {0}")
+ public BadgeAssert text(String value) {
+ final String actualText = element().getText();
+ jdiAssert(actualText, Matchers.is(value), format("%s is not equal to %s", actualText, value));
return this;
}
}
diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java
index 791b1987314..30cad80d51a 100644
--- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java
+++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java
@@ -1,25 +1,27 @@
package com.epam.jdi.light.angular.elements.common;
import com.epam.jdi.light.angular.asserts.BadgeAssert;
+import com.epam.jdi.light.angular.elements.enums.BadgePosition;
+import com.epam.jdi.light.angular.elements.enums.BadgeSize;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.common.UIElement;
import com.epam.jdi.light.elements.interfaces.base.HasClick;
+import com.epam.jdi.light.elements.interfaces.common.IsText;
+
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE;
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM;
+import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL;
/**
* To see an example of Badge web element please visit https://material.angular.io/components/badge/overview.
*/
-public class Badge extends UIBaseElement implements HasClick {
+public class Badge extends UIBaseElement implements HasClick, IsText {
@JDIAction("Get '{name}' badge")
- public UIElement badge() {
- return this.find(".mat-badge-content");
- }
-
- @JDIAction("'{name}' has color '{0}'")
- public boolean color(String color) {
- return getColor().equalsIgnoreCase(color);
+ private UIElement badge() {
+ return core().find(".mat-badge-content");
}
@Override
@@ -28,102 +30,74 @@ public BadgeAssert is() {
}
@JDIAction("Get '{name}' color")
- private String getColor() {
- return getColor(badge().css("background-color"));
- }
-
- private String getColor(String bgValue) {
- switch (bgValue) {
- case "rgba(103, 58, 183, 1)":
- return "violet";
- case "rgba(244, 67, 54, 1)":
- return "red";
- case "rgba(255, 215, 64, 1)":
- return "yellow";
- default:
- return "unknown color";
- }
- }
-
- public boolean size(String value) {
- return getBadgeSize().equalsIgnoreCase(value);
- }
-
- private String getAttrClass() {
- return attr("class");
- }
-
- private String getBadgeSize() {
- return getBadgeSize(getAttrClass());
+ public String color() {
+ return badge().css("background-color");
}
- private String getBadgeSize(String aClass) {
- String medium = "mat-badge-medium";
- String large = "mat-badge-large";
- String small = "mat-badge-small";
- if (aClass.contains(medium)) {
- return "medium";
+ @JDIAction("Get '{name}' size")
+ public BadgeSize size() {
+ if (hasClass("mat-badge-medium")) {
+ return MEDIUM;
}
- if (aClass.contains(large)) {
- return "large";
+ if (hasClass("mat-badge-large")) {
+ return LARGE;
}
- if (aClass.contains(small)) {
- return "small";
+ if (hasClass("mat-badge-small")) {
+ return SMALL;
}
- return "unknown size";
+ return BadgeSize.UNKNOWN;
}
- public boolean positionVertical(String position) {
- return getPositionVertical().equalsIgnoreCase(position);
+ @JDIAction("Get '{name}' vertical position")
+ public BadgePosition positionVertical() {
+ if (hasClass("mat-badge-above")) {
+ return BadgePosition.ABOVE;
+ }
+ if (hasClass("mat-badge-below")) {
+ return BadgePosition.BELOW;
+ }
+ return BadgePosition.UNKNOWN;
}
- private String getPositionVertical() {
- return getPositionVertical(getAttrClass());
-
- }
- private String getPositionVertical(String aClass) {
- String above = "mat-badge-above";
- String below = "mat-badge-below";
- if (aClass.contains(above)) {
- return "above";
+ @JDIAction("Get '{name}' horizontal position")
+ public BadgePosition positionHorizontal() {
+ if (hasClass("mat-badge-before")) {
+ return BadgePosition.BEFORE;
}
- if (aClass.contains(below)) {
- return "below";
+ if (hasClass("mat-badge-after")) {
+ return BadgePosition.AFTER;
}
- return "unknown vertical position";
+ return BadgePosition.UNKNOWN;
}
- public boolean positionHorizontal(String position) {
- return getPositionHorizontal().equalsIgnoreCase(position);
+ @JDIAction(value = "Check that '{name}' is overlap")
+ public boolean isOverlap() {
+ return hasClass("mat-badge-overlap");
}
- private String getPositionHorizontal() {
- return getPositionHorizontal(getAttrClass());
+ @Override
+ public boolean isHidden() {
+ return hasClass("mat-badge-hidden");
}
- private String getPositionHorizontal(String aClass) {
- String before = "mat-badge-before";
- String after = "mat-badge-after";
- if (aClass.contains(before)) {
- return "before";
- }
- if (aClass.contains(after)) {
- return "after";
- }
- return "unknown horizontal position";
+ @Override
+ public boolean isDisplayed() {
+ return !isHidden();
}
- public boolean overlap() {
- return getAttrClass().contains("mat-badge-overlap");
+ @Override
+ public boolean isDisabled() {
+ return hasClass("mat-badge-disabled");
}
- public boolean hidden() {
- return getAttrClass().contains("mat-badge-hidden");
+ @Override
+ public boolean isEnabled() {
+ return !isDisabled();
}
- public boolean disabled() {
- return getAttrClass().contains("mat-badge-disabled");
+ @Override
+ public String getText() {
+ return badge().getText();
}
-
}
diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java
new file mode 100644
index 00000000000..458da6f8116
--- /dev/null
+++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java
@@ -0,0 +1,10 @@
+package com.epam.jdi.light.angular.elements.enums;
+
+public enum BadgePosition {
+ BELOW,
+ ABOVE,
+ AFTER,
+ BEFORE,
+ UNKNOWN
+
+}
diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java
new file mode 100644
index 00000000000..f2b784b8bcd
--- /dev/null
+++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java
@@ -0,0 +1,8 @@
+package com.epam.jdi.light.angular.elements.enums;
+
+public enum BadgeSize {
+ LARGE,
+ MEDIUM,
+ SMALL,
+ UNKNOWN
+}