diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DatePickersTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DatePickersTests.java index 90ccc4a40b..7ce894696c 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DatePickersTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DatePickersTests.java @@ -70,11 +70,11 @@ public class DatePickersTests extends TestsInit { private static final String CHOSEN_YEAR = "1980"; private static final String CHOSEN_MONTH_SWEDISH = "maj"; private static final String CHOSEN_MONTH_CHINESE = "5月"; - private static final String GREEN_COLOR_HEX = "#66bb6a"; - private static final String BLUE_COLOR_HEX = "#1976d2"; - private static final String BLUE_CIRCLE_COLOR_HEX = "#0000ff"; - private static final String RED_CIRCLE_COLOR_HEX = "#f44336"; - private static final String YELLOW_CIRCLE_COLOR_HEX = "#ffeb3b"; + private static final String GREEN_COLOR = "rgba(102, 187, 106, 1)"; + private static final String BLUE_COLOR = "rgba(25, 118, 210, 1)"; + private static final String BLUE_CIRCLE_COLOR_HEX = "rgba(0, 0, 255, 1)"; + private static final String RED_CIRCLE_COLOR_HEX = "rgba(244, 67, 54, 1)"; + private static final String YELLOW_CIRCLE_COLOR_HEX = "rgba(255, 235, 59, 1)"; private static final String FORMATTING_DATE = "02/05/2021"; private static final String FORMATTING_DATE_ISO = "2021-02-05"; private static final String NEXT_MONTH_ICON_CLASS = "mdi-skip-next"; @@ -164,8 +164,8 @@ public void changeDateDatePickerTest() { @Test(description = "Test checks date picker's color") public void colorDatePickerTest() { colorFirstDatePicker.show(); - colorFirstDatePicker.has().color(GREEN_COLOR_HEX); - colorSecondDatePicker.has().color(BLUE_COLOR_HEX); + colorFirstDatePicker.has().color(GREEN_COLOR); + colorSecondDatePicker.has().color(BLUE_COLOR); } @Test(description = "Test checks if element has elevation or not") @@ -286,7 +286,7 @@ public void widthDatePickerTest() { @Test(description = "Test checks color of event circles") public void dateEventsDatePickerTest() { firstDateEventsDatePicker.has().eventColorCirclesNonEmptyList() - .and().properColorsOfEventCircles(GREEN_COLOR_HEX); + .and().properColorsOfEventCircles(GREEN_COLOR); secondDateEventsDatePicker.has().eventColorCirclesNonEmptyList() .and().properColorsOfEventCircles(BLUE_CIRCLE_COLOR_HEX, RED_CIRCLE_COLOR_HEX, YELLOW_CIRCLE_COLOR_HEX); } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/DatePickerAssert.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/DatePickerAssert.java index abee61f8af..e935a13455 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/DatePickerAssert.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/DatePickerAssert.java @@ -51,7 +51,7 @@ public DatePickerAssert date(String date) { @JDIAction(value = "Assert that '{name}' field color is '{0}'", isAssert = true) public DatePickerAssert color(String color) { - jdiAssert(element().getColor(), Matchers.is(color)); + jdiAssert(element().color(), Matchers.is(color)); return this; } @@ -238,17 +238,16 @@ public DatePickerAssert emptyResultDate() { return this; } - // @todo #5048 Check the logic of this method: orientation should not depend on the lines width @JDIAction(value = "Assert that '{name}' has portrait orientation", isAssert = true) public DatePickerAssert portraitOrientation() { - jdiAssert(element().getColorFieldWidth(), Matchers.greaterThan(element().getColorFieldHeight()), + jdiAssert(element().isLandscape(), Matchers.is(false), "DatePicker is not in portrait orientation"); return this; } @JDIAction(value = "Assert that '{name}' has landscape orientation", isAssert = true) public DatePickerAssert landscapeOrientation() { - jdiAssert(element().getColorFieldWidth(), Matchers.lessThan(element().getColorFieldHeight()), + jdiAssert(element().isLandscape(), Matchers.is(true), "Element has not landscape orientation"); return this; } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/DatePicker.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/DatePicker.java index 68aaf7f55e..1d25d637a4 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/DatePicker.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/DatePicker.java @@ -4,6 +4,7 @@ import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.elements.complex.ISetup; +import com.epam.jdi.light.elements.interfaces.base.HasColor; import com.epam.jdi.light.vuetify.annotations.JDatePicker; import com.epam.jdi.light.vuetify.asserts.DatePickerAssert; import com.epam.jdi.light.vuetify.interfaces.HasElevation; @@ -12,7 +13,6 @@ import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; -import org.openqa.selenium.support.Color; import java.lang.reflect.Field; import java.util.List; @@ -28,13 +28,14 @@ /** * To see an example of Date pickers please visit https://v2.vuetifyjs.com/en/components/date-pickers/ */ - -public class DatePicker extends UIBaseElement implements ISetup, HasElevation, HasMeasurement, - HasTheme { +// @todo #5311 Class should be refactored to remove as much as possible get*** methods +public class DatePicker extends UIBaseElement implements + ISetup, HasElevation, HasMeasurement, HasTheme, HasColor { private String root; private String expandedRoot; private static final String EXPANDER = "div.v-input__slot div.v-text-field__slot"; private static final String EXPANDER_MULTIPLE = "div.v-input__control label"; + // @todo #5311 Change locator to do no use any texts, they are depends one locale private static final String NEXT_MONTH = "button[aria-label='Next month']"; private static final String PREVIOUS_MONTH = "button[aria-label='Previous month']"; private static final String DAY_LIST_WITHOUT_EXPANDER = @@ -53,7 +54,8 @@ public class DatePicker extends UIBaseElement implements ISetu private static final String INPUT_FIELD = "//div[@class='v-input__slot']/div/input"; private static final String ICON_NEAR_DATE = "//div[@class='v-input__prepend-outer']/div"; private static final String FORMATTED_DATE = "//p/strong"; - private static final String COLOR_FIELD = "//div[contains(@class, 'v-picker__title')]"; + private static final String TITLE_FIELD = ".v-picker__title"; + private static final String BODY_FIELD = ".v-picker__body"; private static final String DISABLED_DATES = "table > tbody button:disabled"; private static final String ENABLED_DATES = "table > tbody button:enabled"; private static final String NEXT_MONTH_ICON = @@ -151,7 +153,8 @@ private UIElement activeDayOfMonth() { } } - private UIElement changeMonthButton() { + @JDIAction("Get access to change month button of {name}") + public UIElement changeMonthButton() { if (expander().isExist()) { return expandedRoot().find(MONTH_YEAR_FIELD); } else { @@ -218,8 +221,9 @@ private UIElement changeYearSmallButton() { } } - private UIElement colorField() { - return root().find(COLOR_FIELD); + @JDIAction("Get {name}'s title with year, month and date") + public UIElement titleField() { + return root().find(TITLE_FIELD); } private List disabledDates() { @@ -445,9 +449,16 @@ public void changeYearCornerButton() { changeYearSmallButton().click(); } - @JDIAction("Get '{name}' color from color field") - public String getColor() { - return Color.fromString(colorField().css("background-color")).asHex(); + @Override + @JDIAction("Get '{name}' color from title") + public String color() { + return titleField().css("background-color"); + } + + @Override + @JDIAction("Get '{name}' color from body") + public String backgroundColor() { + return core().find(BODY_FIELD).css("background-color"); } @JDIAction("Get '{name}' list of disabled dates") @@ -528,18 +539,8 @@ public void rightClickYear(final String year) { @JDIAction("Get '{name}' list of colors for all event dates") public List getEventCirclesColor() { - return eventColorCircles().stream().map(elem - -> Color.fromString(elem.css("background-color")).asHex()).collect(Collectors.toList()); - } - - @JDIAction("Get '{name}' width of color field") - public int getColorFieldWidth() { - return colorField().getSize().getWidth(); - } - - @JDIAction("Get '{name}' height of color field") - public int getColorFieldHeight() { - return colorField().getSize().getHeight(); + return eventColorCircles().stream().map(elem -> elem.css("background-color")) + .collect(Collectors.toList()); } @JDIAction("Get '{name}' change year button element") @@ -547,11 +548,6 @@ public UIElement getChangeYearButton() { return changeYearButton(); } - @JDIAction("Get '{name}' change month button element") - public UIElement getChangeMonthButton() { - return changeMonthButton(); - } - @JDIAction("Get '{name}' main field element") public UIElement getMainField() { return mainDateField(); @@ -568,6 +564,11 @@ public UIElement getExpandedElement() { return expandedField(); } + @JDIAction("Get if '{name}' has landscape orientation") + public boolean isLandscape() { + return !root().classLike("v-picker--landscape", StringUtils::equals).isEmpty(); + } + @Override @JDIAction("Get if '{name}' is elevated") public boolean isElevated() {