Skip to content

Commit

Permalink
Merge pull request #5444 from jdi-testing/5311
Browse files Browse the repository at this point in the history
#5311 fix landscape and remove color reformating to keep-as-is
  • Loading branch information
pnatashap authored Apr 11, 2024
2 parents c4780fe + 365f72b commit 37157ef
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<DatePickerAssert> implements ISetup, HasElevation, HasMeasurement,
HasTheme {
// @todo #5311 Class should be refactored to remove as much as possible get*** methods
public class DatePicker extends UIBaseElement<DatePickerAssert> 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 =
Expand All @@ -53,7 +54,8 @@ public class DatePicker extends UIBaseElement<DatePickerAssert> 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 =
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<UIElement> disabledDates() {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -528,30 +539,15 @@ public void rightClickYear(final String year) {

@JDIAction("Get '{name}' list of colors for all event dates")
public List<String> 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")
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();
Expand All @@ -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() {
Expand Down

0 comments on commit 37157ef

Please sign in to comment.