From 8edcc1312940af66c6b8ee229db85485be6d8a6b Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 16:01:22 +0300 Subject: [PATCH 01/14] rework Angular element: Button --- .../light/angular/elements/common/Button.java | 46 ++------------- .../angular/elements/complex/BottomSheet.java | 2 +- .../angular/elements/complex/Dialog.java | 2 +- .../elements/complex/NestedDropdownMenu.java | 2 +- .../angular/elements/interfaces/IsButton.java | 56 +++++++++++++++++++ 5 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index 680f63eef4..8620677bea 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -4,60 +4,22 @@ import com.epam.jdi.light.angular.elements.enums.AngularColors; import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; +import com.epam.jdi.light.angular.elements.interfaces.IsButton; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.common.IsText; import com.jdiai.tools.map.MapArray; -public class Button extends UIBaseElement implements HasBadge, HasClick, IsText { +public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, IsButton { - private static final String ICON_LOCATOR = ".//mat-icon"; private static final String LABEL_LOCATOR = ".mdc-button__label"; - @JDIAction(value = "Get if '{name}' is focused") - public boolean focused() { - return core().hasClass("cdk-focused"); - } - - @JDIAction("Get '{name}' color") - public String color() { - if (core().hasAttribute("color")) { - return AngularColors.fromName(core().attr("color")).getColor(); - } - return core().getCssValue("background-color"); - } - - @JDIAction("Get if '{name}' has default color") - public boolean defaultColor() { - return attrs().has("defaultcolor"); - } - @Override @JDIAction("Get '{name}' text") public String getText() { - return core().find(LABEL_LOCATOR).text(); - } - - @JDIAction("Get visual type '{name}'") - public ButtonsTypes visualType() { - MapArray attrsMap = this.attrs(); - for (int i = 0; i < ButtonsTypes.size(); i++) { - if (attrsMap.has(ButtonsTypes.values()[i].getType())) { - return ButtonsTypes.values()[i]; - } - } - return ButtonsTypes.UNDEFINED; - } - - @JDIAction("Get if there is icon inside the button") - public boolean hasIcon() { - return !core().finds(ICON_LOCATOR).isEmpty(); - } - - @JDIAction("Get icon inside the button") - public Icon icon() { - return new Icon().setCore(Icon.class, core().find(ICON_LOCATOR)); + return core().find(LABEL_LOCATOR) + .text(); } @Override diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/BottomSheet.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/BottomSheet.java index 560d283b83..c73a8e834a 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/BottomSheet.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/BottomSheet.java @@ -1,10 +1,10 @@ package com.epam.jdi.light.angular.elements.complex; import com.epam.jdi.light.angular.asserts.BottomSheetAssert; +import com.epam.jdi.light.angular.elements.common.Button; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.elements.complex.WebList; -import com.epam.jdi.light.ui.html.elements.common.Button; import org.openqa.selenium.By; import java.util.List; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Dialog.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Dialog.java index 9325b7bc7d..c00775bfe6 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Dialog.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Dialog.java @@ -1,9 +1,9 @@ package com.epam.jdi.light.angular.elements.complex; import com.epam.jdi.light.angular.asserts.DialogAssert; +import com.epam.jdi.light.angular.elements.common.Button; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; -import com.epam.jdi.light.ui.html.elements.common.Button; import org.openqa.selenium.By; import org.openqa.selenium.Keys; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/NestedDropdownMenu.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/NestedDropdownMenu.java index a62384c18a..3ed6e4b451 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/NestedDropdownMenu.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/NestedDropdownMenu.java @@ -1,12 +1,12 @@ package com.epam.jdi.light.angular.elements.complex; import com.epam.jdi.light.angular.asserts.NestedDropdownMenuAssert; +import com.epam.jdi.light.angular.elements.common.Button; import com.epam.jdi.light.common.ElementArea; 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.complex.WebList; -import com.epam.jdi.light.ui.html.elements.common.Button; import org.openqa.selenium.By; import java.util.ArrayList; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java new file mode 100644 index 0000000000..4d291b99de --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java @@ -0,0 +1,56 @@ +package com.epam.jdi.light.angular.elements.interfaces; + +import com.epam.jdi.light.angular.elements.common.Icon; +import com.epam.jdi.light.angular.elements.enums.AngularColors; +import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.interfaces.base.ICoreElement; +import com.jdiai.tools.map.MapArray; + +/** + * In angular element can be with Button, so this interface can be used to work with it + */ +public interface IsButton extends ICoreElement { + String ICON_LOCATOR = ".//mat-icon"; + + @JDIAction(value = "Get if '{name}' is focused") + default boolean focused() { + return core().hasClass("cdk-focused"); + } + + @JDIAction("Get '{name}' color") + default String color() { + if (core().hasAttribute("color")) { + return AngularColors.fromName(core().attr("color")) + .getColor(); + } + return core().getCssValue("background-color"); + } + + @JDIAction("Get visual type '{name}'") + default ButtonsTypes visualType() { + MapArray attrsMap = this.attrs(); + for (int i = 0; i < ButtonsTypes.size(); i++) { + if (attrsMap.has(ButtonsTypes.values()[i].getType())) { + return ButtonsTypes.values()[i]; + } + } + return ButtonsTypes.UNDEFINED; + } + + @JDIAction("Get if '{name}' has default color") + default boolean defaultColor() { + return attrs().has("defaultcolor"); + } + + @JDIAction("Get if there is icon inside the button") + default boolean hasIcon() { + return !core().finds(ICON_LOCATOR) + .isEmpty(); + } + + @JDIAction("Get icon inside the button") + default Icon icon() { + return new Icon().setCore(Icon.class, core().find(ICON_LOCATOR)); + } +} From 169b3a9709c37633a3d28f03ccd4e05b3cbe2fd9 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 16:07:35 +0300 Subject: [PATCH 02/14] rework Angular element: Button --- .../com/epam/jdi/light/angular/elements/common/Button.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index 8620677bea..a845c6e733 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -1,15 +1,12 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.ButtonAssert; -import com.epam.jdi.light.angular.elements.enums.AngularColors; -import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; import com.epam.jdi.light.angular.elements.interfaces.IsButton; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.common.IsText; -import com.jdiai.tools.map.MapArray; public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, IsButton { From 07319c1c6a956df7af3a9d3f897e1394d53a3626 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 17:06:38 +0300 Subject: [PATCH 03/14] rework Angular element: Button - add HasLink interface --- .../light/angular/elements/common/Button.java | 49 +++++++++++++++- .../angular/elements/interfaces/HasLink.java | 19 +++++++ .../angular/elements/interfaces/IsButton.java | 56 ------------------- 3 files changed, 66 insertions(+), 58 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java delete mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index a845c6e733..7df6dca530 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -1,17 +1,40 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.ButtonAssert; +import com.epam.jdi.light.angular.elements.enums.AngularColors; +import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; -import com.epam.jdi.light.angular.elements.interfaces.IsButton; +import com.epam.jdi.light.angular.elements.interfaces.HasLink; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.common.IsText; +import com.jdiai.tools.map.MapArray; -public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, IsButton { +public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, HasLink { + private static final String ICON_LOCATOR = ".//mat-icon"; private static final String LABEL_LOCATOR = ".mdc-button__label"; + @JDIAction(value = "Get if '{name}' is focused") + public boolean focused() { + return core().hasClass("cdk-focused"); + } + + @JDIAction("Get '{name}' color") + public String color() { + if (core().hasAttribute("color")) { + return AngularColors.fromName(core().attr("color")) + .getColor(); + } + return core().getCssValue("background-color"); + } + + @JDIAction("Get if '{name}' has default color") + public boolean defaultColor() { + return attrs().has("defaultcolor"); + } + @Override @JDIAction("Get '{name}' text") public String getText() { @@ -19,6 +42,28 @@ public String getText() { .text(); } + @JDIAction("Get visual type '{name}'") + public ButtonsTypes visualType() { + MapArray attrsMap = this.attrs(); + for (int i = 0; i < ButtonsTypes.size(); i++) { + if (attrsMap.has(ButtonsTypes.values()[i].getType())) { + return ButtonsTypes.values()[i]; + } + } + return ButtonsTypes.UNDEFINED; + } + + @JDIAction("Get if there is icon inside the button") + public boolean hasIcon() { + return !core().finds(ICON_LOCATOR) + .isEmpty(); + } + + @JDIAction("Get icon inside the button") + public Icon icon() { + return new Icon().setCore(Icon.class, core().find(ICON_LOCATOR)); + } + @Override public ButtonAssert is() { return new ButtonAssert().set(this); diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java new file mode 100644 index 0000000000..4e86e659b7 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java @@ -0,0 +1,19 @@ +package com.epam.jdi.light.angular.elements.interfaces; + +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.interfaces.base.ICoreElement; + +/** + * In angular element can be with Link, so this interface can be used to work with it + */ +public interface HasLink extends ICoreElement { + @JDIAction("Get if there is link inside the button") + default boolean hasLink() { + return core().hasAttribute("href"); + } + + @JDIAction("Get '{name}' reference") + default String ref() { + return core().attr("href"); + } +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java deleted file mode 100644 index 4d291b99de..0000000000 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/IsButton.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.epam.jdi.light.angular.elements.interfaces; - -import com.epam.jdi.light.angular.elements.common.Icon; -import com.epam.jdi.light.angular.elements.enums.AngularColors; -import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; -import com.epam.jdi.light.common.JDIAction; -import com.epam.jdi.light.elements.interfaces.base.ICoreElement; -import com.jdiai.tools.map.MapArray; - -/** - * In angular element can be with Button, so this interface can be used to work with it - */ -public interface IsButton extends ICoreElement { - String ICON_LOCATOR = ".//mat-icon"; - - @JDIAction(value = "Get if '{name}' is focused") - default boolean focused() { - return core().hasClass("cdk-focused"); - } - - @JDIAction("Get '{name}' color") - default String color() { - if (core().hasAttribute("color")) { - return AngularColors.fromName(core().attr("color")) - .getColor(); - } - return core().getCssValue("background-color"); - } - - @JDIAction("Get visual type '{name}'") - default ButtonsTypes visualType() { - MapArray attrsMap = this.attrs(); - for (int i = 0; i < ButtonsTypes.size(); i++) { - if (attrsMap.has(ButtonsTypes.values()[i].getType())) { - return ButtonsTypes.values()[i]; - } - } - return ButtonsTypes.UNDEFINED; - } - - @JDIAction("Get if '{name}' has default color") - default boolean defaultColor() { - return attrs().has("defaultcolor"); - } - - @JDIAction("Get if there is icon inside the button") - default boolean hasIcon() { - return !core().finds(ICON_LOCATOR) - .isEmpty(); - } - - @JDIAction("Get icon inside the button") - default Icon icon() { - return new Icon().setCore(Icon.class, core().find(ICON_LOCATOR)); - } -} From bc448140eed8ed10670b037236123c260fe18284 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 17:09:13 +0300 Subject: [PATCH 04/14] rework Angular element: Button - add ButtonAssert for HasLink methods --- .../light/angular/asserts/ButtonAssert.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java index 3c546d6511..f5e5542177 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java @@ -6,6 +6,7 @@ import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; import com.epam.jdi.light.asserts.generic.UIAssert; import com.epam.jdi.light.common.JDIAction; +import org.hamcrest.Matcher; import org.hamcrest.Matchers; import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; @@ -21,8 +22,7 @@ public ButtonAssert text(String expectedText) { @JDIAction(value = "Assert that '{name}' is focused", isAssert = true) public ButtonAssert focused() { boolean actualFocused = element().focused(); - jdiAssert(actualFocused, Matchers.is(true), - "Element is not focused"); + jdiAssert(actualFocused, Matchers.is(true), "Element is not focused"); return this; } @@ -40,8 +40,7 @@ public ButtonAssert color(AngularColors expectedColor) { @JDIAction(value = "Assert that '{name}' has default color", isAssert = true) public ButtonAssert defaultColor() { - jdiAssert(element().defaultColor(), Matchers.is(true), - "Element doesn't have default color."); + jdiAssert(element().defaultColor(), Matchers.is(true), "Element doesn't have default color."); return this; } @@ -54,8 +53,19 @@ public ButtonAssert visualType(ButtonsTypes expectedType) { @JDIAction(value = "Assert that '{name}' has icon", isAssert = true) public ButtonAssert hasIcon() { - jdiAssert(element().hasIcon(), Matchers.is(true), - "Element doesn't have icon inside"); + jdiAssert(element().hasIcon(), Matchers.is(true), "Element doesn't have icon inside"); + return this; + } + + @JDIAction(value = "Assert that '{name}' has link", isAssert = true) + public ButtonAssert hasLink() { + jdiAssert(element().hasLink(), Matchers.is(true), "Element doesn't have link inside"); + return this; + } + + @JDIAction("Assert that '{name}' ref {0}") + public ButtonAssert ref(Matcher condition) { + jdiAssert(element().ref(), condition); return this; } } From 0076a1ef6d8c0290ea98871cd3ed6e260dab2224 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 17:11:14 +0300 Subject: [PATCH 05/14] rework Angular element: Button - formatting --- .../epam/jdi/light/angular/elements/common/Button.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index 7df6dca530..3c8c66d53b 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -24,8 +24,7 @@ public boolean focused() { @JDIAction("Get '{name}' color") public String color() { if (core().hasAttribute("color")) { - return AngularColors.fromName(core().attr("color")) - .getColor(); + return AngularColors.fromName(core().attr("color")).getColor(); } return core().getCssValue("background-color"); } @@ -38,8 +37,7 @@ public boolean defaultColor() { @Override @JDIAction("Get '{name}' text") public String getText() { - return core().find(LABEL_LOCATOR) - .text(); + return core().find(LABEL_LOCATOR).text(); } @JDIAction("Get visual type '{name}'") @@ -55,8 +53,7 @@ public ButtonsTypes visualType() { @JDIAction("Get if there is icon inside the button") public boolean hasIcon() { - return !core().finds(ICON_LOCATOR) - .isEmpty(); + return !core().finds(ICON_LOCATOR).isEmpty(); } @JDIAction("Get icon inside the button") From dc5602bb883e1b3e81d4aeaaa852b5e3e2f9d82d Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 17:12:22 +0300 Subject: [PATCH 06/14] rework Angular element: Button - formatting --- .../com/epam/jdi/light/angular/asserts/ButtonAssert.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java index f5e5542177..5268bf3b0d 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java @@ -22,7 +22,8 @@ public ButtonAssert text(String expectedText) { @JDIAction(value = "Assert that '{name}' is focused", isAssert = true) public ButtonAssert focused() { boolean actualFocused = element().focused(); - jdiAssert(actualFocused, Matchers.is(true), "Element is not focused"); + jdiAssert(actualFocused, Matchers.is(true), + "Element is not focused"); return this; } @@ -40,7 +41,8 @@ public ButtonAssert color(AngularColors expectedColor) { @JDIAction(value = "Assert that '{name}' has default color", isAssert = true) public ButtonAssert defaultColor() { - jdiAssert(element().defaultColor(), Matchers.is(true), "Element doesn't have default color."); + jdiAssert(element().defaultColor(), Matchers.is(true), + "Element doesn't have default color."); return this; } From 18b53cc76567ee732eb1a482ed2d3369a93f09ae Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 14 Mar 2024 17:14:20 +0300 Subject: [PATCH 07/14] rework Angular element: Button - formatting --- .../java/com/epam/jdi/light/angular/asserts/ButtonAssert.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java index 5268bf3b0d..05ce3f10ad 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java @@ -55,7 +55,8 @@ public ButtonAssert visualType(ButtonsTypes expectedType) { @JDIAction(value = "Assert that '{name}' has icon", isAssert = true) public ButtonAssert hasIcon() { - jdiAssert(element().hasIcon(), Matchers.is(true), "Element doesn't have icon inside"); + jdiAssert(element().hasIcon(), Matchers.is(true), + "Element doesn't have icon inside"); return this; } From 65f7511cb87d66e3d9d0514073cad3a41c7b4f04 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Mon, 18 Mar 2024 16:22:58 +0300 Subject: [PATCH 08/14] rework Angular element: Button - fix hasIcon method - color() returns attr value instead AngularColors.fromName --- .../tests/elements/common/ButtonsTests.java | 19 ++++++++----------- .../light/angular/elements/common/Button.java | 9 +++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java index 4c6c4264ec..0d5977ec3a 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java @@ -1,13 +1,13 @@ package io.github.epam.angular.tests.elements.common; +import java.util.Random; + import com.epam.jdi.light.angular.elements.common.Button; import com.epam.jdi.light.angular.elements.enums.AngularColors; import io.github.epam.TestsInit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Random; - import static com.epam.jdi.light.angular.elements.enums.ButtonsTypes.BASIC; import static com.epam.jdi.light.angular.elements.enums.ButtonsTypes.EXTENDED_FAB; import static com.epam.jdi.light.angular.elements.enums.ButtonsTypes.FAB; @@ -18,21 +18,18 @@ import static com.epam.jdi.light.angular.elements.enums.ButtonsTypes.STROKED; import static com.jdiai.tools.Timer.waitCondition; import static io.github.com.StaticSite.buttonsPage; - -import static org.hamcrest.Matchers.containsString; +import static io.github.com.pages.ButtonsPage.accentColorButtons; import static io.github.com.pages.ButtonsPage.basicButtons; -import static io.github.com.pages.ButtonsPage.basicbuttonLabel; import static io.github.com.pages.ButtonsPage.defaultColorButton; import static io.github.com.pages.ButtonsPage.extendedFabButtons; -import static io.github.com.pages.ButtonsPage.primaryColorButtons; -import static io.github.com.pages.ButtonsPage.accentColorButtons; -import static io.github.com.pages.ButtonsPage.warnColorButtons; import static io.github.com.pages.ButtonsPage.fabButtons; import static io.github.com.pages.ButtonsPage.flatButtons; import static io.github.com.pages.ButtonsPage.iconButtons; import static io.github.com.pages.ButtonsPage.miniFabButtons; +import static io.github.com.pages.ButtonsPage.primaryColorButtons; import static io.github.com.pages.ButtonsPage.raisedButtons; import static io.github.com.pages.ButtonsPage.strokedButtons; +import static io.github.com.pages.ButtonsPage.warnColorButtons; public class ButtonsTests extends TestsInit { Random rand = new Random(); @@ -143,10 +140,10 @@ public void strokedButtonsTest() { @Test(description = "Check buttons colors") public void colorButtonsTest() { primaryColorButtons.get(rand.nextInt(primaryColorButtons.size()) + 1) - .has().color(AngularColors.PRIMARY); + .has().color(AngularColors.PRIMARY.toString()); accentColorButtons.get(rand.nextInt(accentColorButtons.size()) + 1) - .has().color(AngularColors.ACCENT); + .has().color(AngularColors.ACCENT.toString()); warnColorButtons.get(rand.nextInt(warnColorButtons.size()) + 1) - .has().color(AngularColors.WARN.getColor()); + .has().color(AngularColors.WARN.toString()); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index 3c8c66d53b..c3bb0b1e10 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -1,17 +1,17 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.ButtonAssert; -import com.epam.jdi.light.angular.elements.enums.AngularColors; import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; import com.epam.jdi.light.angular.elements.interfaces.HasLink; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; +import com.epam.jdi.light.elements.interfaces.base.HasColor; import com.epam.jdi.light.elements.interfaces.common.IsText; import com.jdiai.tools.map.MapArray; -public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, HasLink { +public class Button extends UIBaseElement implements HasBadge, HasClick, IsText, HasLink, HasColor { private static final String ICON_LOCATOR = ".//mat-icon"; private static final String LABEL_LOCATOR = ".mdc-button__label"; @@ -21,10 +21,11 @@ public boolean focused() { return core().hasClass("cdk-focused"); } + @Override @JDIAction("Get '{name}' color") public String color() { if (core().hasAttribute("color")) { - return AngularColors.fromName(core().attr("color")).getColor(); + return core().attr("color"); } return core().getCssValue("background-color"); } @@ -53,7 +54,7 @@ public ButtonsTypes visualType() { @JDIAction("Get if there is icon inside the button") public boolean hasIcon() { - return !core().finds(ICON_LOCATOR).isEmpty(); + return core().finds(ICON_LOCATOR).isExist(); } @JDIAction("Get icon inside the button") From 461485f0270d128fcba8fd8d9ccdcb6fbdd99af6 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 21 Mar 2024 15:47:47 +0300 Subject: [PATCH 09/14] rework Angular element: Button - modify AngularColors - add CustomColors - deprecate RadioButtonAssert #color(AngularColors expectedColor) --- .../tests/elements/common/ButtonsTests.java | 6 +- .../elements/complex/RadioButtonTests.java | 26 ++++++--- .../light/angular/asserts/ButtonAssert.java | 2 +- .../light/angular/asserts/CheckboxAssert.java | 2 +- .../radiobuttons/RadioButtonAssert.java | 20 ++----- .../angular/elements/enums/AngularColors.java | 55 ++++++------------- .../angular/elements/enums/CustomColors.java | 38 +++++++++++++ .../angular/elements/interfaces/HasBadge.java | 8 +-- 8 files changed, 89 insertions(+), 68 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java index 0d5977ec3a..5df32749e1 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/ButtonsTests.java @@ -140,10 +140,10 @@ public void strokedButtonsTest() { @Test(description = "Check buttons colors") public void colorButtonsTest() { primaryColorButtons.get(rand.nextInt(primaryColorButtons.size()) + 1) - .has().color(AngularColors.PRIMARY.toString()); + .has().color(AngularColors.PRIMARY); accentColorButtons.get(rand.nextInt(accentColorButtons.size()) + 1) - .has().color(AngularColors.ACCENT.toString()); + .has().color(AngularColors.ACCENT); warnColorButtons.get(rand.nextInt(warnColorButtons.size()) + 1) - .has().color(AngularColors.WARN.toString()); + .has().color(AngularColors.WARN); } } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java index cb2cd8e85f..366d0000f4 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java @@ -4,10 +4,22 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.epam.jdi.light.angular.elements.enums.AngularColors.*; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.BLACK_SEMI_TRANSPARENT; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.PURPLE; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.RED; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.YELLOW; import static com.jdiai.tools.Timer.waitCondition; import static io.github.com.StaticSite.radioButtonPage; -import static io.github.com.pages.RadioButtonPage.*; +import static io.github.com.pages.RadioButtonPage.accentRadioButton; +import static io.github.com.pages.RadioButtonPage.basicRadioGroup; +import static io.github.com.pages.RadioButtonPage.beforePositionRadioGroup; +import static io.github.com.pages.RadioButtonPage.colorRadioGroup; +import static io.github.com.pages.RadioButtonPage.disabledRadioGroup; +import static io.github.com.pages.RadioButtonPage.elementPositionRadioGroup; +import static io.github.com.pages.RadioButtonPage.labelPositionRadioGroup; +import static io.github.com.pages.RadioButtonPage.primaryRadioButton; +import static io.github.com.pages.RadioButtonPage.requiredRadioGroup; +import static io.github.com.pages.RadioButtonPage.warnRadioButton; public class RadioButtonTests extends TestsInit { @BeforeClass @@ -79,13 +91,13 @@ public void colorButtonsTest() { colorRadioGroup.show(); colorRadioGroup.is().displayed(); primaryRadioButton.click(); - primaryRadioButton.has().color(PRIMARY); - accentRadioButton.has().color(UNSELECTED); + primaryRadioButton.has().color(PURPLE.getColor()); + accentRadioButton.has().color(BLACK_SEMI_TRANSPARENT.getColor()); warnRadioButton.click(); - warnRadioButton.has().color(WARN); - primaryRadioButton.has().color(UNSELECTED); + warnRadioButton.has().color(RED.getColor()); + primaryRadioButton.has().color(BLACK_SEMI_TRANSPARENT.getColor()); accentRadioButton.click(); - accentRadioButton.has().color(ACCENT); + accentRadioButton.has().color(YELLOW.getColor()); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java index 05ce3f10ad..7252d4ef12 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java @@ -35,7 +35,7 @@ public ButtonAssert color(String expectedColor) { @JDIAction(value = "Assert that '{name}' color is '{0}'", isAssert = true) public ButtonAssert color(AngularColors expectedColor) { - jdiAssert(element().color(), Matchers.is(expectedColor.getColor())); + jdiAssert(element().color(), Matchers.is(expectedColor.getType())); return this; } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java index f6c55111c0..6c99c03be3 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java @@ -73,7 +73,7 @@ public CheckboxAssert notRequired() { @JDIAction(value = "Assert that '{name}' angular color is '{0}'", isAssert = true) public CheckboxAssert color(AngularColors expectedColor) { - jdiAssert(element().color(), Matchers.is(expectedColor.getColor())); + jdiAssert(element().color(), Matchers.is(expectedColor)); return this; } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioButtonAssert.java index 57dec8a895..28cc3de221 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/radiobuttons/RadioButtonAssert.java @@ -1,13 +1,12 @@ 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; +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; + public class RadioButtonAssert extends UIAssert { @Override @@ -24,12 +23,6 @@ public RadioButtonAssert enabled() { return this; } - @JDIAction(value = "Assert that '{name}' color is '{0}'", isAssert = true) - public RadioButtonAssert color(AngularColors expectedColor) { - jdiAssert(AngularColors.fromColor(element().color()), Matchers.is(expectedColor)); - return this; - } - @JDIAction(value = "Assert that '{name}' color is '{0}'", isAssert = true) public RadioButtonAssert color(String expectedColor) { jdiAssert(element().color(), Matchers.is(expectedColor)); @@ -38,15 +31,13 @@ public RadioButtonAssert color(String expectedColor) { @JDIAction(value = "'{name}' element label is in before position", isAssert = true) public RadioButtonAssert labelBeforePosition() { - jdiAssert(element().hasLabelBeforePosition(), Matchers.is(true), - "Radio button label is not in before position"); + jdiAssert(element().hasLabelBeforePosition(), Matchers.is(true), "Radio button label is not in before position"); return this; } @JDIAction(value = "'{name}' element label is in before position", isAssert = true) public RadioButtonAssert labelAfterPosition() { - jdiAssert(element().hasLabelBeforePosition(), Matchers.is(false), - "Radio button label is not in after position"); + jdiAssert(element().hasLabelBeforePosition(), Matchers.is(false), "Radio button label is not in after position"); return this; } @@ -64,7 +55,8 @@ public RadioButtonAssert notChecked() { @JDIAction(value = "'{name}' has label with value '{0}'", isAssert = true) public RadioButtonAssert label(String value) { - jdiAssert(element().label().getValue(), Matchers.is(value)); + jdiAssert(element().label() + .getValue(), Matchers.is(value)); return this; } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java index 1f8af4edd8..c6e034670c 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java @@ -2,49 +2,28 @@ import java.util.Arrays; -public enum AngularColors { +public enum AngularColors { - PRIMARY("mat-primary", "rgba(103, 58, 183, 1)"), - ACCENT("mat-accent", "rgba(255, 215, 64, 1)"), - WARN("mat-warn", "rgba(244, 67, 54, 1)"), - UNSELECTED("unselected", "rgba(0, 0, 0, 0.54)"), - DEFAULT("default", "rgba(0, 0, 0, 1)"), - UNDEFINED("undefined", "rgba(0, 0, 0, 0)"); + PRIMARY("primary"), + ACCENT("accent"), + WARN("warn"), + UNSELECTED("unselected"), + DEFAULT("default"), + UNDEFINED("undefined"); - private final String styleName; - private final String color; + String type; - AngularColors(String styleName, String color) { - this.styleName = styleName; - this.color = color; + AngularColors(String type) { + this.type = type; } - - public String getStyle() { - return this.styleName; - } - - public String getColor() { - return this.color; - } - - public static AngularColors fromStyle(String styleName) { - return Arrays.stream(AngularColors.values()) - .filter(c -> c.styleName.equalsIgnoreCase(styleName)) - .findFirst() - .orElse(AngularColors.UNDEFINED); - } - - public static AngularColors fromColor(String color) { - return Arrays.stream(AngularColors.values()) - .filter(c -> c.color.equalsIgnoreCase(color)) - .findFirst() - .orElse(AngularColors.UNDEFINED); + public String getType() { + return this.type; } - public static AngularColors fromName(String name) { - return Arrays.stream(AngularColors.values()) - .filter(c -> c.name().equalsIgnoreCase(name)) + public static AngularColors fromType(String type) { + return Arrays.stream(values()) + .filter(t -> t.type.equalsIgnoreCase(type)) .findFirst() - .orElse(AngularColors.UNDEFINED); + .orElse(UNDEFINED); } -} +} \ No newline at end of file diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java new file mode 100644 index 0000000000..bfd293d8ea --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java @@ -0,0 +1,38 @@ +package com.epam.jdi.light.angular.elements.enums; + +import java.util.Arrays; + +public enum CustomColors { + + PURPLE("rgba(103, 58, 183, 1)"), + YELLOW("rgba(255, 215, 64, 1)"), + RED("rgba(244, 67, 54, 1)"), + BLACK_SEMI_TRANSPARENT("rgba(0, 0, 0, 0.54)"), + BLACK("rgba(0, 0, 0, 1)"), + TRANSPARENT("rgba(0, 0, 0, 0)"); + + private final String color; + + CustomColors(String color) { + this.color = color; + } + + public String getColor() { + return this.color; + } + + public static CustomColors fromColor(String color) { + return Arrays.stream(CustomColors.values()) + .filter(c -> c.color.equalsIgnoreCase(color)) + .findFirst() + .orElse(CustomColors.TRANSPARENT); + } + + public static CustomColors fromName(String name) { + return Arrays.stream(CustomColors.values()) + .filter(c -> c.name() + .equalsIgnoreCase(name)) + .findFirst() + .orElse(CustomColors.TRANSPARENT); + } +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java index cb45bdd032..e6f95700f1 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java @@ -1,5 +1,8 @@ package com.epam.jdi.light.angular.elements.interfaces; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import com.epam.jdi.light.angular.elements.common.Badge; import com.epam.jdi.light.angular.elements.enums.AngularColors; import com.epam.jdi.light.angular.elements.enums.BadgePosition; @@ -7,9 +10,6 @@ import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.interfaces.base.ICoreElement; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * In angular any element can be with Badge, so this interface can be used to work with it */ @@ -74,6 +74,6 @@ default boolean isBadgeEnabled() { } default AngularColors badgeColor() { - return AngularColors.fromName(core().attr("matbadgecolor")); + return AngularColors.fromType(core().attr("matbadgecolor")); } } From 99aeb0c8969457c400f3626766e6008fee8d6cc0 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 21 Mar 2024 15:49:01 +0300 Subject: [PATCH 10/14] rework Angular element: Button - modify AngularColors - add CustomColors - deprecate RadioButtonAssert #color(AngularColors expectedColor) --- .../jdi/light/angular/elements/enums/CustomColors.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java index bfd293d8ea..9fdc20c34a 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CustomColors.java @@ -27,12 +27,4 @@ public static CustomColors fromColor(String color) { .findFirst() .orElse(CustomColors.TRANSPARENT); } - - public static CustomColors fromName(String name) { - return Arrays.stream(CustomColors.values()) - .filter(c -> c.name() - .equalsIgnoreCase(name)) - .findFirst() - .orElse(CustomColors.TRANSPARENT); - } } From 6cd3801aef29ed6b1f1f23b01fbf441ccf4dad6c Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 21 Mar 2024 15:57:26 +0300 Subject: [PATCH 11/14] rework Angular element: Button - modify AngularColors - add CustomColors - deprecate RadioButtonAssert #color(AngularColors expectedColor) --- .../epam/jdi/light/angular/elements/enums/AngularColors.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java index c6e034670c..204ad1d0f8 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/AngularColors.java @@ -26,4 +26,4 @@ public static AngularColors fromType(String type) { .findFirst() .orElse(UNDEFINED); } -} \ No newline at end of file +} From 0bf85b0d52c4bc7479c04f015a146c52cebbb9e2 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 21 Mar 2024 16:14:24 +0300 Subject: [PATCH 12/14] rework Angular element: Button - modify AngularColors - add CustomColors - deprecate RadioButtonAssert #color(AngularColors expectedColor) --- .../tests/elements/common/CheckboxTests.java | 20 ++++++++++--------- .../light/angular/asserts/CheckboxAssert.java | 7 ------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java index 048fc10d59..c3704a8545 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java @@ -1,15 +1,17 @@ package io.github.epam.angular.tests.elements.common; -import com.epam.jdi.light.angular.elements.enums.AngularColors; import io.github.epam.TestsInit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static io.github.com.enums.CheckBoxAlignPosition.AFTER; -import static io.github.com.enums.CheckBoxAlignPosition.BEFORE; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.BLACK_SEMI_TRANSPARENT; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.PURPLE; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.RED; +import static com.epam.jdi.light.angular.elements.enums.CustomColors.YELLOW; import static com.jdiai.tools.Timer.waitCondition; - import static io.github.com.StaticSite.checkBoxPage; +import static io.github.com.enums.CheckBoxAlignPosition.AFTER; +import static io.github.com.enums.CheckBoxAlignPosition.BEFORE; import static io.github.com.pages.CheckBoxPage.accentColorCheckbox; import static io.github.com.pages.CheckBoxPage.basicCheckbox; import static io.github.com.pages.CheckBoxPage.disabledCheckbox; @@ -86,16 +88,16 @@ public void isRequiredCheckboxTest() { public void angularColorCheckBoxTest() { //Check color for checkboxes with attribute 'color' primaryColorCheckbox.uncheck(); - primaryColorCheckbox.has().color(AngularColors.UNSELECTED); + primaryColorCheckbox.has().color(BLACK_SEMI_TRANSPARENT.getColor()); primaryColorCheckbox.check(); - primaryColorCheckbox.has().color(AngularColors.PRIMARY); + primaryColorCheckbox.has().color(PURPLE.getColor()); accentColorCheckbox.check(); - accentColorCheckbox.has().color(AngularColors.ACCENT); + accentColorCheckbox.has().color(YELLOW.getColor()); warnColorCheckbox.check(); - warnColorCheckbox.has().color(AngularColors.WARN); + warnColorCheckbox.has().color(RED.getColor()); //Check color for checkbox without attribute 'color' requiredCheckbox.check(); - requiredCheckbox.has().color(AngularColors.ACCENT); + requiredCheckbox.has().color(YELLOW.getColor()); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java index 6c99c03be3..9ec714f52c 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java @@ -1,7 +1,6 @@ package com.epam.jdi.light.angular.asserts; import com.epam.jdi.light.angular.elements.common.Checkbox; -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; @@ -71,12 +70,6 @@ public CheckboxAssert notRequired() { return this; } - @JDIAction(value = "Assert that '{name}' angular color is '{0}'", isAssert = true) - public CheckboxAssert color(AngularColors expectedColor) { - jdiAssert(element().color(), Matchers.is(expectedColor)); - return this; - } - @JDIAction(value = "Assert that '{name}' color is '{0}'", isAssert = true) public CheckboxAssert color(String expectedColor) { jdiAssert(element().color(), Matchers.is(expectedColor)); From 88efc244ac034dbd44870248124250c3f9461025 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 21 Mar 2024 16:18:24 +0300 Subject: [PATCH 13/14] -remove extra raw --- .../epam/angular/tests/elements/complex/RadioButtonTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java index 366d0000f4..52e5b12b47 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/RadioButtonTests.java @@ -99,5 +99,4 @@ public void colorButtonsTest() { accentRadioButton.click(); accentRadioButton.has().color(YELLOW.getColor()); } - } From 1d9273e85e64e8d758b0e9823a3007145d0441c9 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 26 Mar 2024 15:45:49 +0300 Subject: [PATCH 14/14] - move HasLink interface to core module --- .../com/epam/jdi/light/angular/elements/common/Button.java | 2 +- .../com/epam/jdi/light/elements/interfaces/base}/HasLink.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) rename {jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces => jdi-light-core/src/main/java/com/epam/jdi/light/elements/interfaces/base}/HasLink.java (78%) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index c3bb0b1e10..e3768c6e36 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -3,11 +3,11 @@ import com.epam.jdi.light.angular.asserts.ButtonAssert; import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; -import com.epam.jdi.light.angular.elements.interfaces.HasLink; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.base.HasColor; +import com.epam.jdi.light.elements.interfaces.base.HasLink; import com.epam.jdi.light.elements.interfaces.common.IsText; import com.jdiai.tools.map.MapArray; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java b/jdi-light-core/src/main/java/com/epam/jdi/light/elements/interfaces/base/HasLink.java similarity index 78% rename from jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java rename to jdi-light-core/src/main/java/com/epam/jdi/light/elements/interfaces/base/HasLink.java index 4e86e659b7..d8c7770988 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasLink.java +++ b/jdi-light-core/src/main/java/com/epam/jdi/light/elements/interfaces/base/HasLink.java @@ -1,7 +1,6 @@ -package com.epam.jdi.light.angular.elements.interfaces; +package com.epam.jdi.light.elements.interfaces.base; import com.epam.jdi.light.common.JDIAction; -import com.epam.jdi.light.elements.interfaces.base.ICoreElement; /** * In angular element can be with Link, so this interface can be used to work with it