Skip to content

Commit

Permalink
#5446 fix locators, remove elements outside of element
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed Apr 30, 2024
1 parent 71406a2 commit d80b7a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ public void elevationDatePickerTest() {
iconsDatePicker.is().notElevated();
}

@Test(description = "Test checks next month/previous month icons type")
public void iconsDatePickerTest() {
iconsDatePicker.show();
iconsDatePicker.has().nextMonthIconClass(NEXT_MONTH_ICON_CLASS)
.and().previousMonthIconClass(PREVIOUS_MONTH_ICON_CLASS)
.and().additionalYearIcon();
}

@Test(description = "Test checks multiple dates selection")
public void multipleChosenDatesDatePickerTest() {
multipleDatePicker.show();
Expand Down Expand Up @@ -294,16 +286,17 @@ public void dateEventsDatePickerTest() {
@Test(description = "Test checks date picker code before and after date selection")
public void testActivePickerDatePicker() {
waitCondition(() -> activePickerDatePicker.isVisible());
jdiAssert(activePickerDatePicker.getCode(), is("null"), "Before any date in Active date picker " +
"is selected: active picker code is not null");
// @todo #5446 Fix code check in tests, it is not a part of the picker
/*jdiAssert(activePickerDatePicker.getCode(), is("null"), "Before any date in Active date picker " +
"is selected: active picker code is not null");*/
activePickerDatePicker.expand();
activePickerDatePicker.selectYear(CHOSEN_YEAR);
activePickerDatePicker.selectMonth(CHOSEN_MONTH);
activePickerDatePicker.selectDay(Integer.toString(CHOSEN_DAY));
activePickerDatePicker.has().resultDate(LocalDate.of(Integer.parseInt(CHOSEN_YEAR),
Month.valueOf(CHOSEN_MONTH.toUpperCase(Locale.ROOT)), CHOSEN_DAY).toString());
jdiAssert(activePickerDatePicker.getCode(), is("DATE"), "After some date in Active date picker " +
"was selected: active picker code is not correct");
/*jdiAssert(activePickerDatePicker.getCode(), is("DATE"), "After some date in Active date picker " +
"was selected: active picker code is not correct");*/
}

@Test(description = "Expandable date picker test")
Expand Down Expand Up @@ -353,8 +346,7 @@ public void formattedDateDatePickerTest() {
currentYear, currentMonth, CHOSEN_DAY).format(formatterMMDDYYYY));
writableFormattingDatePicker.clear();
writableFormattingDatePicker.setDate(FORMATTING_DATE);
writableFormattingDatePicker.has().resultDate(FORMATTING_DATE)
.and().formattedDate(FORMATTING_DATE_ISO);
writableFormattingDatePicker.has().resultDate(FORMATTING_DATE);
readonlyFormattingDatePicker.has().dateFieldReadonlyAttribute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,6 @@ public DatePickerAssert nonClickableDisabledDates() {
return this;
}

@JDIAction(value = "Assert that '{name}' next month icon class is '{0}'", isAssert = true)
public DatePickerAssert nextMonthIconClass(String nextMonthIconClass) {
jdiAssert(element().getNextMonthIconClass(), Matchers.containsString(nextMonthIconClass));
return this;
}

@JDIAction(value = "Assert that '{name}' previous month icon class is '{0}'", isAssert = true)
public DatePickerAssert previousMonthIconClass(String previousMonthIconClass) {
jdiAssert(element().getPreviousMonthIconClass(), Matchers.containsString(previousMonthIconClass));
return this;
}

@JDIAction(value = "Assert that '{name}' additional year icon exists", isAssert = true)
public DatePickerAssert additionalYearIcon() {
jdiAssert(element().getAdditionalYearIcon().isExist(), Matchers.is(true),
"DatePicker hasn't additional year icon");
return this;
}

@JDIAction(value = "Assert that '{name}' chosen dates are '{0}'", isAssert = true)
public DatePickerAssert properSetOfActiveDays(Set<String> days) {
jdiAssert(element().getAllActiveDaysOfMonth(), Matchers.containsInAnyOrder(days.toArray()));
Expand Down Expand Up @@ -209,12 +190,6 @@ public DatePickerAssert mainDateField() {
return this;
}

@JDIAction(value = "Assert that '{name}' formatted date field has date '{0}'", isAssert = true)
public DatePickerAssert formattedDate(String formattedDate) {
jdiAssert(element().getFormattedDate(), Matchers.is(formattedDate));
return this;
}

@JDIAction(value = "Assert that '{name}' date field has readonly attribute", isAssert = true)
public DatePickerAssert dateFieldReadonlyAttribute() {
jdiAssert(element().getDateFieldReadonlyAttribute(), Matchers.is("true"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,28 @@ public class DatePicker extends UIBaseElement<DatePickerAssert> implements
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 =
"//div[@class='v-date-picker-table v-date-picker-table--date theme--light']/table";
".//div[contains(@class, 'v-date-picker-table')]/table";
private static final String MAIN_FIELD =
"//div[@class='v-picker__title__btn v-date-picker-title__date v-picker__title__btn--active']/div";
private static final String MONTH_YEAR_FIELD = "//div[@class='v-date-picker-header__value']//button";
private static final String ACTIVE_DAY_OF_MONTH = "//table/tbody//button[contains(@class, 'active')]";
".//div[contains(@class, 'v-picker__title__btn v-date-picker-title__date v-picker__title__btn--active']/div";
private static final String MONTH_YEAR_FIELD = ".//div[@class='v-date-picker-header__value']//button";
private static final String ACTIVE_DAY_OF_MONTH = ".//table/tbody//button[contains(@class, 'v-btn--active')]";
private static final String MONTH_LIST_WITHOUT_EXPANDER =
"//div[@class='v-date-picker-table v-date-picker-table--month theme--light']/table";
private static final String YEAR = "//div[@class='v-date-picker-header__value']/div/button";
".//div[@class='v-date-picker-table v-date-picker-table--month theme--light']/table";
private static final String YEAR = ".v-date-picker-title__year";
private static final String YEAR_LIST = "//ul";
private static final String YEAR_SMALL = "//div[@class='v-date-picker-title']/div";
private static final String RESULT_DATE_WITH_EXPANDER = "//input";
private static final String ACTIVE_PICKER_CODE = "//code";
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 ICON_NEAR_DATE = "//div[contains(@class, 'v-input__prepend-outer')]/div";
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 =
"//div[@class='v-date-picker-header theme--light']/button[2]/span/*";
private static final String PREVIOUS_MONTH_ICON =
"//div[@class='v-date-picker-header theme--light']/button[1]/span/*";
private static final String ADDITIONAL_YEAR_ICON =
"div.v-picker__title__btn.v-date-picker-title__year i:only-child";
private static final String SHOWN_MULTIPLE_DATES = "//div[@class='v-select__selections']/span/span";
private static final String OUTLINED_DATE = "//button[contains(@class, 'outlined theme')]";
private static final String EVENT_COLOR_CIRCLE = "table > tbody button > div.v-date-picker-table__events > div";
private static final String EVENT_COLOR_CIRCLE = ".v-date-picker-table__events > div";
private static final String CLEAR_BUTTON = "//button[@aria-label = 'clear icon']";

@Override
Expand Down Expand Up @@ -193,14 +183,6 @@ private UIElement resultDateField() {
}
}

private UIElement activePickerCode() {
if (expander().isExist()) {
return root().find(ACTIVE_PICKER_CODE);
} else {
return null;
}
}

private UIElement inputField() {
return root().find(INPUT_FIELD);
}
Expand All @@ -209,10 +191,6 @@ private UIElement iconNearDate() {
return root().find(ICON_NEAR_DATE);
}

private UIElement formattedDate() {
return root().find(FORMATTED_DATE);
}

private UIElement changeYearSmallButton() {
if (expander().isExist()) {
return expandedRoot().find(YEAR_SMALL);
Expand All @@ -234,18 +212,6 @@ private List<UIElement> enabledDates() {
return root().finds(ENABLED_DATES);
}

private UIElement nextMonthIcon() {
return root().find(NEXT_MONTH_ICON);
}

private UIElement previousMonthIcon() {
return root().find(PREVIOUS_MONTH_ICON);
}

private UIElement additionalYearIcon() {
return root().find(ADDITIONAL_YEAR_ICON);
}

private List<UIElement> allActiveDates() {
if (expander().isExist()) {
return expandedRoot().finds(ACTIVE_DAY_OF_MONTH);
Expand Down Expand Up @@ -407,11 +373,6 @@ public String getResultDate() {
return resultDateField().getText();
}

@JDIAction("Get '{name}' code for active date picker")
public String getCode() {
return activePickerCode().getText();
}

@JDIAction("Get '{name}' clear button")
public UIElement getClearButton() {
return clearButton();
Expand All @@ -434,11 +395,6 @@ public void setDate(final String date) {
iconNearDate().click();
}

@JDIAction("Get '{name}' ISO formatted date")
public String getFormattedDate() {
return formattedDate().getText();
}

@JDIAction("Get '{name}' readonly attribute of date field")
public String getDateFieldReadonlyAttribute() {
return inputField().attr("readonly");
Expand Down Expand Up @@ -483,21 +439,6 @@ public List<UIElement> getDisabledDatesElements() {
return disabledDates();
}

@JDIAction("Get '{name}' class of next month icon")
public String getNextMonthIconClass() {
return nextMonthIcon().attr("class");
}

@JDIAction("Get '{name}' class of previous month icon")
public String getPreviousMonthIconClass() {
return previousMonthIcon().attr("class");
}

@JDIAction("Get '{name}' additional year icon element")
public UIElement getAdditionalYearIcon() {
return additionalYearIcon();
}

@JDIAction("Get all '{name}' active days of month")
public List<String> getAllActiveDaysOfMonth() {
return allActiveDates().stream().map(elem
Expand Down

0 comments on commit d80b7a8

Please sign in to comment.