diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java index dee71067e2..5ce88b94a8 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java @@ -11,6 +11,7 @@ import io.github.com.pages.ProgressBarPage; import io.github.com.pages.ProgressSpinnerPage; import io.github.com.pages.RadioButtonPage; +import io.github.com.pages.SelectPage; @JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/") public class StaticSite { @@ -36,6 +37,9 @@ public class StaticSite { @Url("autocompletes") public static AutocompletePage autocompletePage; + @Url("select") + public static SelectPage selectPage; + @Url("radio_button") public static RadioButtonPage radioButtonPage; 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 7c2975e6cf..fde7853e55 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 @@ -19,7 +19,6 @@ public class AngularPage extends WebPage { public static ToolbarSection toolbarSection; public static SlideToggleSection slideToggleSection; public static InputSection inputSection; - public static SelectSection selectSection; public static ListSection listSection; public static GridListSection gridListSection; public static SnackbarSection snackbarSection; diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SelectSection.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/SelectPage.java similarity index 88% rename from jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SelectSection.java rename to jdi-light-angular-tests/src/main/java/io/github/com/pages/SelectPage.java index e1977484a7..4298687b76 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/SelectSection.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/SelectPage.java @@ -1,45 +1,48 @@ -package io.github.com.pages.sections; - -import com.epam.jdi.light.angular.elements.common.Checkbox; -import com.epam.jdi.light.angular.elements.complex.MaterialSelector; -import com.epam.jdi.light.angular.elements.complex.NativeSelector; -import com.epam.jdi.light.elements.composite.Section; -import com.epam.jdi.light.ui.html.elements.common.Text; - -public class SelectSection extends Section { - public static MaterialSelector basicMatSelect; - public static NativeSelector basicNativeSelect; - - public static MaterialSelector twoBindingSelect; - public static Text selectBindingConfirm; - - public static MaterialSelector formMatSelect; - public static Text formMatSelectConfirm; - - public static NativeSelector formNativeSelect; - public static Text formNativeSelectConfirm; - - public static MaterialSelector formMatFeatureSelect; - public static NativeSelector formNativeFeatureSelect; - - public static MaterialSelector disableMatSelect; - public static NativeSelector disableNativeSelect; - public static Checkbox disableCheckboxSelect; - - public static MaterialSelector resetMatSelect; - public static NativeSelector resetNativeSelect; - - public static MaterialSelector optionGroupsMatSelect; - public static NativeSelector optionGroupsNativeSelect; - - public static MaterialSelector multipleSelect; - - public static MaterialSelector customTriggerTextSelect; - - public static MaterialSelector noOptionRippleSelect; - - public static MaterialSelector customPanelStylingSelect; - - public static MaterialSelector matErrorStateMatcherSelect; - public static NativeSelector nativeErrorStateMatcherSelect; -} +package io.github.com.pages; + +import com.epam.jdi.light.angular.elements.common.Checkbox; +import com.epam.jdi.light.angular.elements.complex.MaterialSelector; +import com.epam.jdi.light.angular.elements.complex.NativeSelector; +import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; +import com.epam.jdi.light.ui.html.elements.common.Text; + +public class SelectPage extends NewAngularPage { + + public static MaterialSelector basicMatSelect; + public static NativeSelector basicNativeSelect; + + public static MaterialSelector twoBindingSelect; + public static Text selectBindingConfirm; + + public static MaterialSelector formMatSelect; + public static Text formMatSelectConfirm; + + public static NativeSelector formNativeSelect; + public static Text formNativeSelectConfirm; + + public static MaterialSelector formMatFeatureSelect; + public static NativeSelector formNativeFeatureSelect; + + public static MaterialSelector disableMatSelect; + public static NativeSelector disableNativeSelect; + public static Checkbox disableCheckboxSelect; + + public static MaterialSelector resetMatSelect; + public static NativeSelector resetNativeSelect; + + public static MaterialSelector optionGroupsMatSelect; + public static NativeSelector optionGroupsNativeSelect; + + public static MaterialSelector multipleSelect; + + public static MaterialSelector customTriggerTextSelect; + + public static MaterialSelector noOptionRippleSelect; + + @UI("#custom-panel-styling-select") + public static MaterialSelector customPanelStylingSelect; + + public static MaterialSelector matErrorStateMatcherSelect; + public static NativeSelector nativeErrorStateMatcherSelect; + +} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicMatSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicMatSelectTests.java index afd93a9d12..9a917d8ee2 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicMatSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicMatSelectTests.java @@ -1,32 +1,30 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collections; -import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.basicMatSelect; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.selectPage; +import static io.github.com.pages.SelectPage.basicMatSelect; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class BasicMatSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { - angularPage.shouldBeOpened(); - basicMatSelect.show(); + selectPage.open(); + waitCondition(() -> selectPage.isOpened()); + selectPage.checkOpened(); } - @Test + @Test(description = "Test checks label value") public void checkLabelValue() { basicMatSelect.label().has().value("Favorite food"); } - @Test + @Test(description = "Test checks expand-collapse functionality") public void checkSelectorExpanded() { basicMatSelect.expand(); basicMatSelect.is().expanded(); @@ -34,29 +32,17 @@ public void checkSelectorExpanded() { basicMatSelect.is().collapsed(); } - @Test - public void checkSelectorCollapsed() { - basicMatSelect.collapse(); - basicMatSelect.is().collapsed(); - } - - @Test - public void checkOptionCanBeSelectedByIndex() { - basicMatSelect.select(ELEMENT.startIndex + 1); - basicMatSelect.is().selected(PIZZA); - } - - @Test + @Test(description = "Test checks that element does not contain disabled options") public void checkListDisabledOptions() { basicMatSelect.has().listDisabled(Collections.EMPTY_LIST); } - @Test + @Test(description = "Test checks that element contains certain enabled options") public void checkListEnabledOptions() { basicMatSelect.has().listEnabled(Arrays.asList(STEAK, PIZZA, TACOS)); } - @Test + @Test(description = "Test checks that element contains certain options") public void checkAvailableOptions() { basicMatSelect.assertThat().values(hasItems(TACOS, STEAK, PIZZA)); } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicNativeSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicNativeSelectTests.java index 52ae8c0fc1..d37196b279 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicNativeSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/BasicNativeSelectTests.java @@ -1,55 +1,42 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collections; -import static io.github.com.pages.sections.SelectSection.basicNativeSelect; +import static io.github.com.pages.SelectPage.basicNativeSelect; import static org.hamcrest.Matchers.*; -// TODO Move to the new page -@Ignore public class BasicNativeSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { basicNativeSelect.show(); } - @Test + @Test(description = "Test checks label value") public void checkLabelValue() { - basicNativeSelect.label().has().value("Cars *"); + basicNativeSelect.label().has().value("Cars"); } - @Test + @Test(description = "Test checks preselected value in the field") public void checkPreselectedValue() { basicNativeSelect.verify().selected(matchesPattern("[a-zA-Z]+")); } - @Test + @Test(description = "Test checks option can be selected by name") public void checkOptionCanBeSelectedByName() { basicNativeSelect.select(SAAB); basicNativeSelect.is().selected(SAAB); } - @Test - public void checkListDisabledOptions() { - basicNativeSelect.has().listDisabled(Collections.EMPTY_LIST); - } - - @Test - public void checkListEnabledOptions() { - basicNativeSelect.has().listEnabled(Arrays.asList(VOLVO, SAAB, MERCEDES, AUDI)); - } - - @Test + @Test(description = "Test checks available groups") public void checkAvailableGroups() { basicNativeSelect.is().groups(Collections.EMPTY_LIST); } - @Test + @Test(description = "Test checks available options") public void checkAvailableOptions() { basicNativeSelect.assertThat().values(hasItem(AUDI)).values(hasItems(AUDI, VOLVO, SAAB, MERCEDES)); } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomPanelStylingSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomPanelStylingSelectTests.java index 960f745bfb..c86594dcfc 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomPanelStylingSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomPanelStylingSelectTests.java @@ -1,16 +1,15 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.customPanelStylingSelect; +import static com.jdiai.tools.Timer.sleep; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.pages.SelectPage.customPanelStylingSelect; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class CustomPanelStylingSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { @@ -37,7 +36,7 @@ public void checkGreenOptionCanBeSelectedByName() { } @Test - public void checkBlueOptionCanBeSelectedByName() { + public void checkBlueOptionCanBeSelectedByName() throws InterruptedException { customPanelStylingSelect.select(BLUE); customPanelStylingSelect.is().selected(BLUE); customPanelStylingSelect.has().color(0, 0, 255, 0.5); diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomTriggerTextSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomTriggerTextSelectTests.java index 8f2e19a319..befdbab892 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomTriggerTextSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/CustomTriggerTextSelectTests.java @@ -1,23 +1,23 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.customTriggerTextSelect; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.selectPage; +import static io.github.com.pages.SelectPage.customTriggerTextSelect; + -// TODO Move to the new page -@Ignore public class CustomTriggerTextSelectTests extends TestsSelectBase { private String[] multiOptions = new String[1]; @BeforeMethod(alwaysRun = true) public void before() { - angularPage.shouldBeOpened(); - customTriggerTextSelect.show(); + selectPage.open(); + waitCondition(() -> selectPage.isOpened()); + selectPage.checkOpened(); } @Test diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableMatSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableMatSelectTests.java index 16e6cd1ba2..31019f51e6 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableMatSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableMatSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.disableCheckboxSelect; -import static io.github.com.pages.sections.SelectSection.disableMatSelect; +import static io.github.com.pages.SelectPage.disableCheckboxSelect; +import static io.github.com.pages.SelectPage.disableMatSelect; -// TODO Move to the new page -@Ignore public class DisableMatSelectTests extends TestsSelectBase { private static final String ARIA_DISABLED = "aria-disabled"; private static final String OPTION_2_DISABLED = "Option 2 (disabled)"; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableNativeSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableNativeSelectTests.java index 3c60a6c084..a2de4d34cf 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableNativeSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/DisableNativeSelectTests.java @@ -1,16 +1,13 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.disableNativeSelect; +import static io.github.com.pages.SelectPage.disableNativeSelect; -// TODO Move to the new page -@Ignore public class DisableNativeSelectTests extends TestsSelectBase { private static final String DISABLED = "disabled"; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatFeatureSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatFeatureSelectTests.java index d90628a22c..e41c734020 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatFeatureSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatFeatureSelectTests.java @@ -1,16 +1,13 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.formMatFeatureSelect; +import static io.github.com.pages.SelectPage.formMatFeatureSelect; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class FormMatFeatureSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatSelectTests.java index 7d48e0b44d..2d2f7b1169 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormMatSelectTests.java @@ -1,19 +1,16 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collections; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.formMatSelect; -import static io.github.com.pages.sections.SelectSection.formMatSelectConfirm; +import static io.github.com.pages.SelectPage.formMatSelect; +import static io.github.com.pages.SelectPage.formMatSelectConfirm; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class FormMatSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeFeatureSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeFeatureSelectTests.java index 03b721c7a1..a4f2f283cc 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeFeatureSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeFeatureSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.formNativeFeatureSelect; +import static io.github.com.pages.SelectPage.formNativeFeatureSelect; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class FormNativeFeatureSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeSelectTests.java index 5ba05a8cd3..d0e12115d6 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/FormNativeSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.formNativeSelect; -import static io.github.com.pages.sections.SelectSection.formNativeSelectConfirm; +import static io.github.com.pages.SelectPage.formNativeSelect; +import static io.github.com.pages.SelectPage.formNativeSelectConfirm; import static org.hamcrest.Matchers.*; -// TODO Move to the new page -@Ignore public class FormNativeSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MatErrorStateMatcherSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MatErrorStateMatcherSelectTests.java index e746cead37..9d08360497 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MatErrorStateMatcherSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MatErrorStateMatcherSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.matErrorStateMatcherSelect; +import static io.github.com.pages.SelectPage.matErrorStateMatcherSelect; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class MatErrorStateMatcherSelectTests extends TestsSelectBase { private static final String CLEAR = "Clear"; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MultipleSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MultipleSelectTests.java index 42039c4045..57f2fbffd7 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MultipleSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/MultipleSelectTests.java @@ -1,25 +1,24 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.multipleSelect; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.selectPage; +import static io.github.com.pages.SelectPage.multipleSelect; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class MultipleSelectTests extends TestsSelectBase { private String[] multiOptions = new String[3]; private int[] multiSelect = new int[1]; @BeforeMethod(alwaysRun = true) public void before() { - angularPage.shouldBeOpened(); - multipleSelect.show(); + selectPage.open(); + waitCondition(() -> selectPage.isOpened()); + selectPage.checkOpened(); } @Test diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NativeErrorStateMatcherSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NativeErrorStateMatcherSelectTests.java index ebd80ebae7..fb2a33a873 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NativeErrorStateMatcherSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NativeErrorStateMatcherSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collections; -import static io.github.com.pages.sections.SelectSection.nativeErrorStateMatcherSelect; +import static io.github.com.pages.SelectPage.nativeErrorStateMatcherSelect; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class NativeErrorStateMatcherSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NoOptionRippleSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NoOptionRippleSelectTests.java index 41e3b3fa3d..5c1d2c3e0a 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NoOptionRippleSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/NoOptionRippleSelectTests.java @@ -1,16 +1,13 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.noOptionRippleSelect; +import static io.github.com.pages.SelectPage.noOptionRippleSelect; import static org.hamcrest.Matchers.hasItems; -// TODO Move to the new page -@Ignore public class NoOptionRippleSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsMatSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsMatSelectTests.java index 82931f8ef9..62c0662073 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsMatSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsMatSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.optionGroupsMatSelect; +import static io.github.com.pages.SelectPage.optionGroupsMatSelect; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class OptionGroupsMatSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsNativeSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsNativeSelectTests.java index 99b8847677..2abbffb7b4 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsNativeSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/OptionGroupsNativeSelectTests.java @@ -1,15 +1,12 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.optionGroupsNativeSelect; +import static io.github.com.pages.SelectPage.optionGroupsNativeSelect; -// TODO Move to the new page -@Ignore public class OptionGroupsNativeSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetMatSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetMatSelectTests.java index bb5d1dbcc6..b4436e4b10 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetMatSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetMatSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.resetMatSelect; +import static io.github.com.pages.SelectPage.resetMatSelect; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class ResetMatSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetNativeSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetNativeSelectTests.java index 3b69e29a35..b0e728c961 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetNativeSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/ResetNativeSelectTests.java @@ -1,17 +1,14 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.pages.sections.SelectSection.resetNativeSelect; +import static io.github.com.pages.SelectPage.resetNativeSelect; import static org.hamcrest.Matchers.*; -// TODO Move to the new page -@Ignore public class ResetNativeSelectTests extends TestsSelectBase { @BeforeMethod(alwaysRun = true) public void before() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TestsSelectBase.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TestsSelectBase.java index 38e6401bb4..45f293f1ef 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TestsSelectBase.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TestsSelectBase.java @@ -2,19 +2,16 @@ import io.github.epam.TestsInit; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.disableCheckboxSelect; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.selectPage; +import static io.github.com.pages.SelectPage.disableCheckboxSelect; -// TODO Move to the new page -@Ignore public class TestsSelectBase extends TestsInit { public static final String PIZZA = "Pizza"; public static final String STEAK = "Steak"; @@ -60,8 +57,9 @@ public class TestsSelectBase extends TestsInit { @BeforeMethod(alwaysRun = true) public void beforeStartTest() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); + selectPage.open(); + waitCondition(() -> selectPage.isOpened()); + selectPage.checkOpened(); } public static Map> getPokemonsMap() { diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TwoBindingSelectTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TwoBindingSelectTests.java index d4cc1160b3..12ca4321f8 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TwoBindingSelectTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/select/TwoBindingSelectTests.java @@ -1,18 +1,15 @@ package io.github.epam.angular.tests.elements.complex.select; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.Arrays; -import static io.github.com.pages.sections.SelectSection.selectBindingConfirm; -import static io.github.com.pages.sections.SelectSection.twoBindingSelect; +import static io.github.com.pages.SelectPage.selectBindingConfirm; +import static io.github.com.pages.SelectPage.twoBindingSelect; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.matchesPattern; -// TODO Move to the new page -@Ignore public class TwoBindingSelectTests extends TestsSelectBase { private static final String NONE = "None"; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/MaterialSelectorAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SelectAssert.java similarity index 59% rename from jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/MaterialSelectorAssert.java rename to jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SelectAssert.java index 5db77a9494..0f95d0c5b0 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/MaterialSelectorAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SelectAssert.java @@ -1,128 +1,128 @@ -package com.epam.jdi.light.angular.asserts; - -import com.epam.jdi.light.angular.elements.complex.MaterialSelector; -import com.epam.jdi.light.asserts.generic.UIAssert; -import com.epam.jdi.light.common.JDIAction; -import org.hamcrest.Matcher; -import org.hamcrest.Matchers; - -import java.util.List; -import java.util.Map; - -import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; -import static com.jdiai.tools.EnumUtils.getEnumValue; -import static com.jdiai.tools.LinqUtils.toStringArray; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; - -public class MaterialSelectorAssert extends UIAssert { - @JDIAction("Assert that '{name}' expanded") - public MaterialSelectorAssert expanded() { - jdiAssert(element().isExpanded(), Matchers.is(true)); - return this; - } - - @JDIAction("Assert that '{name}' collapsed") - public MaterialSelectorAssert collapsed() { - jdiAssert(element().isCollapsed(), Matchers.is(true)); - return this; - } - - @JDIAction("Assert that '{0}' option selected for '{name}'") - public MaterialSelectorAssert selected(final Matcher condition) { - jdiAssert(element().selected(), condition); - return this; - } - - @JDIAction("Assert that '{0}' option selected for '{name}'") - public MaterialSelectorAssert selected(final String option) { - return selected(Matchers.is(option)); - } - - public > MaterialSelectorAssert selected(final T option) { - return selected(getEnumValue(option)); - } - - public > MaterialSelectorAssert value(final T option) { - jdiAssert(element().values(), hasItem(getEnumValue(option))); - return this; - } - - @JDIAction("Assert that '{name}' value '{0}'") - public MaterialSelectorAssert value(final Matcher condition) { - return values(hasItem(condition)); - } - - @JDIAction("Assert that '{name}' has value '{0}'") - public MaterialSelectorAssert value(final String value) { - return values(hasItem(value)); - } - - @JDIAction("Assert that '{name}' values '{0}'") - public MaterialSelectorAssert values(final Matcher> condition) { - jdiAssert(element().values(), condition); - return this; - } - - public MaterialSelectorAssert values(final String... values) { - return values(hasItems(values)); - } - - public MaterialSelectorAssert values(final List values) { - return values(toStringArray(values)); - } - - @JDIAction("Assert that '{name}' has groups '{0}'") - public MaterialSelectorAssert groups(final Matcher> condition) { - jdiAssert(element().groups(), condition); - return this; - } - - public MaterialSelectorAssert groups(final List groups) { - return groups(toStringArray(groups)); - } - - public MaterialSelectorAssert groups(final String... values) { - return groups(hasItems(values)); - } - - @JDIAction("Assert that '{name}' has groups and options '{0}'") - public MaterialSelectorAssert groupsAndOptions(final Map> expectedGroupsAndOptions) { - jdiAssert(element().groupsAndOptions(), Matchers.is(expectedGroupsAndOptions)); - return this; - } - - @JDIAction("Assert that '{name}' has enabled values '{0}'") - public MaterialSelectorAssert listEnabled(final Matcher> condition) { - jdiAssert(element().listEnabled(), condition); - return this; - } - - public MaterialSelectorAssert listEnabled(final List listEnabled) { - return listEnabled(toStringArray(listEnabled)); - } - - public MaterialSelectorAssert listEnabled(final String... values) { - return listEnabled(hasItems(values)); - } - - @JDIAction("Assert that '{name}' has disabled values '{0}'") - public MaterialSelectorAssert listDisabled(final Matcher> condition) { - jdiAssert(element().listDisabled(), condition); - return this; - } - - public MaterialSelectorAssert listDisabled(final List listDisabled) { - return listDisabled(toStringArray(listDisabled)); - } - - public MaterialSelectorAssert listDisabled(final String... values) { - return listDisabled(hasItems(values)); - } - - @JDIAction("Assert that rgba({0}, {1}, {2}, {3}) is the specified color") - public MaterialSelectorAssert color(final int red, final int green, final int blue, final double a) { - jdiAssert(element().color(red, green, blue, a), Matchers.is(true)); - return this; - } -} +package com.epam.jdi.light.angular.asserts; + +import com.epam.jdi.light.angular.elements.complex.MaterialSelector; +import com.epam.jdi.light.asserts.generic.UIAssert; +import com.epam.jdi.light.common.JDIAction; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; + +import java.util.List; +import java.util.Map; + +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; +import static com.jdiai.tools.EnumUtils.getEnumValue; +import static com.jdiai.tools.LinqUtils.toStringArray; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; + +public class SelectAssert extends UIAssert { + @JDIAction("Assert that '{name}' expanded") + public SelectAssert expanded() { + jdiAssert(element().isExpanded(), Matchers.is(true)); + return this; + } + + @JDIAction("Assert that '{name}' collapsed") + public SelectAssert collapsed() { + jdiAssert(element().isCollapsed(), Matchers.is(true)); + return this; + } + + @JDIAction("Assert that '{0}' option selected for '{name}'") + public SelectAssert selected(final Matcher condition) { + jdiAssert(element().selected(), condition); + return this; + } + + @JDIAction("Assert that '{0}' option selected for '{name}'") + public SelectAssert selected(final String option) { + return selected(Matchers.is(option)); + } + + public > SelectAssert selected(final T option) { + return selected(getEnumValue(option)); + } + + public > SelectAssert value(final T option) { + jdiAssert(element().values(), hasItem(getEnumValue(option))); + return this; + } + + @JDIAction("Assert that '{name}' value '{0}'") + public SelectAssert value(final Matcher condition) { + return values(hasItem(condition)); + } + + @JDIAction("Assert that '{name}' has value '{0}'") + public SelectAssert value(final String value) { + return values(hasItem(value)); + } + + @JDIAction("Assert that '{name}' values '{0}'") + public SelectAssert values(final Matcher> condition) { + jdiAssert(element().values(), condition); + return this; + } + + public SelectAssert values(final String... values) { + return values(hasItems(values)); + } + + public SelectAssert values(final List values) { + return values(toStringArray(values)); + } + + @JDIAction("Assert that '{name}' has groups '{0}'") + public SelectAssert groups(final Matcher> condition) { + jdiAssert(element().groups(), condition); + return this; + } + + public SelectAssert groups(final List groups) { + return groups(toStringArray(groups)); + } + + public SelectAssert groups(final String... values) { + return groups(hasItems(values)); + } + + @JDIAction("Assert that '{name}' has groups and options '{0}'") + public SelectAssert groupsAndOptions(final Map> expectedGroupsAndOptions) { + jdiAssert(element().groupsAndOptions(), Matchers.is(expectedGroupsAndOptions)); + return this; + } + + @JDIAction("Assert that '{name}' has enabled values '{0}'") + public SelectAssert listEnabled(final Matcher> condition) { + jdiAssert(element().listEnabled(), condition); + return this; + } + + public SelectAssert listEnabled(final List listEnabled) { + return listEnabled(toStringArray(listEnabled)); + } + + public SelectAssert listEnabled(final String... values) { + return listEnabled(hasItems(values)); + } + + @JDIAction("Assert that '{name}' has disabled values '{0}'") + public SelectAssert listDisabled(final Matcher> condition) { + jdiAssert(element().listDisabled(), condition); + return this; + } + + public SelectAssert listDisabled(final List listDisabled) { + return listDisabled(toStringArray(listDisabled)); + } + + public SelectAssert listDisabled(final String... values) { + return listDisabled(hasItems(values)); + } + + @JDIAction("Assert that rgba({0}, {1}, {2}, {3}) is the specified color") + public SelectAssert color(final int red, final int green, final int blue, final double a) { + jdiAssert(element().color(red, green, blue, a), Matchers.is(true)); + return this; + } +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/MaterialSelector.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/MaterialSelector.java index 6f6151c923..86e9c8f1bd 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/MaterialSelector.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/MaterialSelector.java @@ -1,6 +1,6 @@ package com.epam.jdi.light.angular.elements.complex; -import com.epam.jdi.light.angular.asserts.MaterialSelectorAssert; +import com.epam.jdi.light.angular.asserts.SelectAssert; import com.epam.jdi.light.angular.elements.composite.MaterialSelectorContainer; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; @@ -19,8 +19,8 @@ * To see an example of MaterialSelector web element please visit https://material.angular.io/components/select/overview. */ -public class MaterialSelector extends UIBaseElement implements HasLabel { - public String toggle = "//*[@id='%s']//div[contains(@class,'mat-select-arrow')][not(contains(@class, 'wrapper'))]"; +public class MaterialSelector extends UIBaseElement implements HasLabel { + public String toggle = "//*[@id='%s']//div[contains(@class,'mat-mdc-select-arrow')][not(contains(@class, 'wrapper'))]"; public String hintLocator = "//*[@id='%s']/ancestor::mat-form-field//mat-hint"; public String errorLocator = "//*[@id='%s']/ancestor::mat-form-field//mat-error"; public String smart = "smart: "; @@ -60,7 +60,7 @@ public void collapse() { @JDIAction(value = "Is '{name}' expanded", level = DEBUG, timeout = 0) public boolean isExpanded() { setupLocators(); - return this.hasAttribute("aria-owns"); + return "true".equalsIgnoreCase(this.core().attr("aria-expanded")); } @JDIAction(value = "Is '{name}' collapsed", level = DEBUG, timeout = 0) @@ -229,8 +229,8 @@ public UIElement error() { } @Override - public MaterialSelectorAssert is() { - return new MaterialSelectorAssert().set(this); + public SelectAssert is() { + return new SelectAssert().set(this); } protected UIElement toggle() { @@ -238,4 +238,44 @@ protected UIElement toggle() { this.core().locator.printLocator().replace(smartSharp, "") .replace(cssSharp, "").replace("'", "")))); } + + @JDIAction("Get '{name}' name") + public String name() { + return core().getAttribute("name"); + } + + @JDIAction("Is '{name}' required") + public boolean required() { + return attrs().has("required"); + } + + @JDIAction("Is '{name}' disabled") + public boolean disabled() { + return attrs().has("disabled"); + } + + @JDIAction("Is '{name}' multiple") + public boolean multiple() { + return attrs().has("multiple"); + } + + @JDIAction("Is '{name}' hide single selection indicator") + public boolean hideSingleSelectionIndicator() { + return attrs().has("hidesingleselectionindicator"); + } + + @JDIAction("Is '{name}' label disabled") + public boolean labelDisabled() { + return core().getAttribute("aria-disabled").equalsIgnoreCase("true"); + } + + @JDIAction("Is '{name}' label required") + public boolean labelRequired() { + return core().getAttribute("aria-required").equalsIgnoreCase("true"); + } + + @JDIAction("Get '{name}' aria-label") + public String ariaLabel() { + return core().getAttribute("aria-label"); + } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/composite/MaterialSelectorContainer.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/composite/MaterialSelectorContainer.java index 0d33894e14..5047d94f54 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/composite/MaterialSelectorContainer.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/composite/MaterialSelectorContainer.java @@ -1,216 +1,216 @@ -package com.epam.jdi.light.angular.elements.composite; - -import com.epam.jdi.light.common.JDIAction; -import com.epam.jdi.light.elements.common.UIElement; -import com.epam.jdi.light.elements.complex.WebList; -import com.epam.jdi.light.elements.composite.Section; -import org.openqa.selenium.By; -import org.openqa.selenium.Point; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.jdiai.tools.StringUtils.format; - -public class MaterialSelectorContainer extends Section { - public String backdropSelectPanel = "div.mat-select-panel.mat-primary"; - public String groupsAndOptionsList = "div.mat-select-panel.mat-primary mat-optgroup"; - public String matOptionSpan = "mat-option span"; - public String matOptions = "mat-option"; - - public WebList list() { - return getOptions(); - } - - @JDIAction("Check that '{name}' is displayed") - @Override - public boolean isDisplayed() { - return getBackdropSelectPanel().isDisplayed(); - } - - @JDIAction("Check that '{name}' is hidden") - @Override - public boolean isHidden() { - return getBackdropSelectPanel().isHidden(); - } - - /** - * Select the specified element by the value. - * - * @param value string value - */ - @JDIAction("Select {0} for '{name}'") - public void select(String value) { - if (value == null) return; - WebList options = getOptions(); - options.get(value).click(); - } - - /** - * Select the specified element by the index. - * - * @param index integer value - */ - @JDIAction("Select '{0}' in '{name}'") - public void select(int index) { - WebList options = getOptions(); - options.get(index).click(); - } - - /** - * Select the specified elements by the value. - * - * @param values string values - */ - @JDIAction("Select {0} for '{name}'") - public void multipleSelect(String... values) { - WebList options = getOptions(); - for (String str : values) { - options.get(str).click(); - } - collapsePanel(); - } - - /** - * Select the specified elements by the index. - * - * @param indexes integer indexes - */ - @JDIAction("Select {0} for '{name}'") - public void multipleSelect(int... indexes) { - WebList options = getOptions(); - for (int index : indexes) { - options.get(index).click(); - } - collapsePanel(); - } - - /** - * Get the elements values. - * - * @return List<String> values - */ - @JDIAction("Get '{name}' values") - public List values() { - List values = new ArrayList<>(); - WebList options = getOptions(matOptionSpan); - options.forEach(option -> values.add(option.getValue())); - collapsePanel(); - return values; - } - - private WebList getOptions() { - return new WebList(By.cssSelector(matOptionSpan)); - } - - private WebList getOptions(String css) { - return new WebList(By.cssSelector(css)); - } - - /** - * Get the available selector groups. - * - * @return List<String> list of available groups - */ - @JDIAction("Get '{name}' groups") - public List getGroups() { - List groups = new ArrayList<>(); - WebList webList = new WebList(By.cssSelector(groupsAndOptionsList)); - int groupSize = webList.values().size(); - for (int i = 0; i < groupSize; i++) { - String stringGroupsAndOptions = webList.values().get(i); - List listGroupsAndOptions = Stream.of(stringGroupsAndOptions.split("\n")) - .collect(Collectors.toCollection(ArrayList::new)); - groups.add(listGroupsAndOptions.get(0)); - } - collapsePanel(); - return groups; - } - - /** - * Get the available selector groups and options. - * - * @return Map> map of available groups and options - */ - @JDIAction("Get '{name}' groups and options") - public Map> getMapGroupsAndOptions() { - Map> map = new LinkedHashMap<>(); - WebList webList = new WebList(By.cssSelector(groupsAndOptionsList)); - int groupSize = webList.values().size(); - for (int i = 0; i < groupSize; i++) { - String stringGroupsAndOptions = webList.values().get(i); - List listGroupsAndOptions = Stream.of(stringGroupsAndOptions.split("\n")) - .collect(Collectors.toCollection(ArrayList::new)); - String key = listGroupsAndOptions.remove(0); - map.put(key, listGroupsAndOptions); - } - collapsePanel(); - return map; - } - - /** - * Get the list of enabled elements. - * - * @return List<String> enabled values - */ - @JDIAction("Get '{name}' enabled values") - public List listEnabled() { - List list = getOptions(matOptions).stream() - .filter(e -> !e.hasAttribute("disabled") && e.attr("aria-disabled").contains("false")) - .map(e -> e.text().trim()).collect(Collectors.toList()); - collapsePanel(); - return list; - } - - /** - * Get the list of disabled elements. - * - * @return List<String> disabled values - */ - @JDIAction("Get '{name}' disabled values") - public List listDisabled() { - List list = getOptions(matOptions).stream() - .filter(e -> e.hasAttribute("disabled") || e.attr("aria-disabled").contains("true")) - .map(e -> e.text().trim()).collect(Collectors.toList()); - collapsePanel(); - return list; - } - - /** - * Check the element background has a color with the specified parameters. - * - * @param red decimal representation of color Red of the form rgba(R,G,B,a) - * @param green decimal representation of color Green of the form rgba(R,G,B,a) - * @param blue decimal representation of color Blue of the form rgba(R,G,B,a) - * @param a opacity of the color of the form rgba(R,G,B,a) - * @return boolean is background has a specified color - */ - @JDIAction("Check that rgba({0}, {1}, {2}, {3}) is the specified color") - public boolean color(final int red, final int green, final int blue, final double a) { - boolean hasColor = getBackdropSelectPanel().css("background-color") - .equalsIgnoreCase(format("rgba(%s, %s, %s, %s)", red, green, blue, a)); - collapsePanel(); - return hasColor; - } - - /** - * Collapse backdrop select panel. - */ - @JDIAction("Collapse '{name}' select panel") - public void collapsePanel() { - getBackdropSelectPanel().core().click(getPointOutsidePanel().getX(), getPointOutsidePanel().getY()); - } - - protected UIElement getBackdropSelectPanel() { - return new UIElement(By.cssSelector(backdropSelectPanel)); - } - - protected Point getPointOutsidePanel() { - UIElement uiElement = getBackdropSelectPanel(); - return new Point(uiElement.core().getRect().getWidth() + 2, uiElement.core().getRect().getHeight() + 2); - } -} +package com.epam.jdi.light.angular.elements.composite; + +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.common.UIElement; +import com.epam.jdi.light.elements.complex.WebList; +import com.epam.jdi.light.elements.composite.Section; +import org.openqa.selenium.By; +import org.openqa.selenium.Point; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.jdiai.tools.StringUtils.format; + +public class MaterialSelectorContainer extends Section { + public String backdropSelectPanel = "div.mat-mdc-select-panel.mat-primary"; + public String groupsAndOptionsList = "div.mat-select-panel.mat-primary mat-optgroup"; + public String matOptionSpan = "mat-option span"; + public String matOptions = "mat-option"; + + public WebList list() { + return getOptions(); + } + + @JDIAction("Check that '{name}' is displayed") + @Override + public boolean isDisplayed() { + return getBackdropSelectPanel().isDisplayed(); + } + + @JDIAction("Check that '{name}' is hidden") + @Override + public boolean isHidden() { + return getBackdropSelectPanel().isHidden(); + } + + /** + * Select the specified element by the value. + * + * @param value string value + */ + @JDIAction("Select {0} for '{name}'") + public void select(String value) { + if (value == null) return; + WebList options = getOptions(); + options.get(value).click(); + } + + /** + * Select the specified element by the index. + * + * @param index integer value + */ + @JDIAction("Select '{0}' in '{name}'") + public void select(int index) { + WebList options = getOptions(); + options.get(index).click(); + } + + /** + * Select the specified elements by the value. + * + * @param values string values + */ + @JDIAction("Select {0} for '{name}'") + public void multipleSelect(String... values) { + WebList options = getOptions(); + for (String str : values) { + options.get(str).click(); + } + collapsePanel(); + } + + /** + * Select the specified elements by the index. + * + * @param indexes integer indexes + */ + @JDIAction("Select {0} for '{name}'") + public void multipleSelect(int... indexes) { + WebList options = getOptions(); + for (int index : indexes) { + options.get(index).click(); + } + collapsePanel(); + } + + /** + * Get the elements values. + * + * @return List<String> values + */ + @JDIAction("Get '{name}' values") + public List values() { + List values = new ArrayList<>(); + WebList options = getOptions(matOptionSpan); + options.forEach(option -> values.add(option.getValue())); + collapsePanel(); + return values; + } + + private WebList getOptions() { + return new WebList(By.cssSelector(matOptionSpan)); + } + + private WebList getOptions(String css) { + return new WebList(By.cssSelector(css)); + } + + /** + * Get the available selector groups. + * + * @return List<String> list of available groups + */ + @JDIAction("Get '{name}' groups") + public List getGroups() { + List groups = new ArrayList<>(); + WebList webList = new WebList(By.cssSelector(groupsAndOptionsList)); + int groupSize = webList.values().size(); + for (int i = 0; i < groupSize; i++) { + String stringGroupsAndOptions = webList.values().get(i); + List listGroupsAndOptions = Stream.of(stringGroupsAndOptions.split("\n")) + .collect(Collectors.toCollection(ArrayList::new)); + groups.add(listGroupsAndOptions.get(0)); + } + collapsePanel(); + return groups; + } + + /** + * Get the available selector groups and options. + * + * @return Map> map of available groups and options + */ + @JDIAction("Get '{name}' groups and options") + public Map> getMapGroupsAndOptions() { + Map> map = new LinkedHashMap<>(); + WebList webList = new WebList(By.cssSelector(groupsAndOptionsList)); + int groupSize = webList.values().size(); + for (int i = 0; i < groupSize; i++) { + String stringGroupsAndOptions = webList.values().get(i); + List listGroupsAndOptions = Stream.of(stringGroupsAndOptions.split("\n")) + .collect(Collectors.toCollection(ArrayList::new)); + String key = listGroupsAndOptions.remove(0); + map.put(key, listGroupsAndOptions); + } + collapsePanel(); + return map; + } + + /** + * Get the list of enabled elements. + * + * @return List<String> enabled values + */ + @JDIAction("Get '{name}' enabled values") + public List listEnabled() { + List list = getOptions(matOptions).stream() + .filter(e -> !e.hasAttribute("disabled") && e.attr("aria-disabled").contains("false")) + .map(e -> e.text().trim()).collect(Collectors.toList()); + collapsePanel(); + return list; + } + + /** + * Get the list of disabled elements. + * + * @return List<String> disabled values + */ + @JDIAction("Get '{name}' disabled values") + public List listDisabled() { + List list = getOptions(matOptions).stream() + .filter(e -> e.hasAttribute("disabled") || e.attr("aria-disabled").contains("true")) + .map(e -> e.text().trim()).collect(Collectors.toList()); + collapsePanel(); + return list; + } + + /** + * Check the element background has a color with the specified parameters. + * + * @param red decimal representation of color Red of the form rgba(R,G,B,a) + * @param green decimal representation of color Green of the form rgba(R,G,B,a) + * @param blue decimal representation of color Blue of the form rgba(R,G,B,a) + * @param a opacity of the color of the form rgba(R,G,B,a) + * @return boolean is background has a specified color + */ + @JDIAction("Check that rgba({0}, {1}, {2}, {3}) is the specified color") + public boolean color(final int red, final int green, final int blue, final double a) { + boolean hasColor = getBackdropSelectPanel().css("background-color") + .equalsIgnoreCase(format("rgba(%s, %s, %s, %s)", red, green, blue, a)); + collapsePanel(); + return hasColor; + } + + /** + * Collapse backdrop select panel. + */ + @JDIAction("Collapse '{name}' select panel") + public void collapsePanel() { + getBackdropSelectPanel().core().click(getPointOutsidePanel().getX(), getPointOutsidePanel().getY()); + } + + protected UIElement getBackdropSelectPanel() { + return new UIElement(By.cssSelector(backdropSelectPanel)); + } + + protected Point getPointOutsidePanel() { + UIElement uiElement = getBackdropSelectPanel(); + return new Point(uiElement.core().getRect().getWidth() + 2, uiElement.core().getRect().getHeight() + 2); + } +}