From 6665de5556d45759dd2409830b79a4a2960d457d Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Tue, 9 Apr 2024 22:11:43 -0500 Subject: [PATCH 1/2] #5314 clear Inputs control from notclear methods --- .../tables/ExternalPaginationTable.java | 2 +- .../vuetify/tests/common/InputsTests.java | 26 +++---- .../tests/complex/AutocompletesTests.java | 2 +- .../tests/complex/DataIteratorsTests.java | 6 +- .../tests/complex/DataTablesTests.java | 20 ++--- .../tests/complex/TimePickersTests.java | 7 +- .../vuetify/tests/complex/TreeViewTests.java | 4 +- .../light/vuetify/asserts/InputAssert.java | 56 +++----------- .../light/vuetify/elements/common/Input.java | 76 +++++++------------ 9 files changed, 72 insertions(+), 127 deletions(-) diff --git a/jdi-light-vuetify-tests/src/main/java/io/github/com/custom/tables/ExternalPaginationTable.java b/jdi-light-vuetify-tests/src/main/java/io/github/com/custom/tables/ExternalPaginationTable.java index 548d0bc67b..6fb53df3e6 100644 --- a/jdi-light-vuetify-tests/src/main/java/io/github/com/custom/tables/ExternalPaginationTable.java +++ b/jdi-light-vuetify-tests/src/main/java/io/github/com/custom/tables/ExternalPaginationTable.java @@ -31,6 +31,6 @@ public void previousPage() { @JDIAction("Show required items value in {name}") public void itemsPerPage(String value) { - itemPerPageInput.clearAndTypeText(value); + itemPerPageInput.text(value); } } diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/common/InputsTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/common/InputsTests.java index b961541a1b..ba2c97ec58 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/common/InputsTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/common/InputsTests.java @@ -45,7 +45,7 @@ public void disabledInputTest() { @Test(description = "Test checks if input has label or not") public void labelInputTest() { hideDetailsMainInput.show(); - hideDetailsMainInput.has().label(); + hideDetailsMainInput.has().label("Main input"); fewErrorsCountInput.show(); fewErrorsCountInput.has().noLabel(); } @@ -54,20 +54,18 @@ public void labelInputTest() { public void typeTextInputTest() { String textToType = "Some text"; hideDetailsAnotherInput.show(); - hideDetailsAnotherInput.has().textField(); - hideDetailsAnotherInput.typeText(textToType); - hideDetailsAnotherInput.has().typedText() - .and().typedText(textToType); + hideDetailsAnotherInput.has().textInput(); + hideDetailsAnotherInput.text(textToType); + hideDetailsAnotherInput.has().text(textToType); fewErrorsCountInput.show(); - fewErrorsCountInput.has().notTextField(); + fewErrorsCountInput.has().notTextInput(); } @Test(description = "Test checks that input has text in slot") public void hintInputTest() { hintInput.show(); - hintInput.has().textInSlot() - .and().textInSlot("Input"); + hintInput.has().text("Input"); } @Test(description = "Test checks that input switch changes input's messages : hint, persistent-hint") @@ -97,15 +95,13 @@ public void loadingInputTest() { public void rulesInputTest() { String incorrectTextToType = "Some text"; String correctTextToType = "test@gmail.com"; - rulesInput.has().textField(); - rulesInput.typeText(incorrectTextToType); - rulesInput.has().typedText(); - rulesInput.has().typedText(incorrectTextToType); + rulesInput.has().textInput(); + rulesInput.text(incorrectTextToType); + rulesInput.has().text(incorrectTextToType); rulesInput.has().errorMessage("Invalid e-mail.") .and().has().messagesCount(1); - rulesInput.clearAndTypeText(correctTextToType); - rulesInput.has().typedText(); - rulesInput.has().typedText(correctTextToType); + rulesInput.text(correctTextToType); + rulesInput.has().text(correctTextToType); rulesInput.has().noErrorMessages(); } diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java index fb7caa91c9..7fb369f561 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java @@ -94,7 +94,7 @@ public void filterAutocompletesTest() { filterStateAutocomplete.is().disabled(); filterEditButton.click(); filterStateAutocomplete.is().closed(); - filterName.typeText(name); + filterName.text(name); filterStateAutocomplete.expand(); filterStateAutocomplete.is().expanded(); filterStateAutocomplete.select(valueToSelect); diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataIteratorsTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataIteratorsTests.java index 17ffea8070..89c53e8800 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataIteratorsTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataIteratorsTests.java @@ -72,9 +72,9 @@ public static void headerFooterTest() { @Test(description = "Test checks data iterator sort") public static void filterDataIteratorTest() { - filterDataIterator.filterDataSearchField.clearAndTypeText(FROZEN_YOGURT.value()); + filterDataIterator.filterDataSearchField.text(FROZEN_YOGURT.value()); filterDataIterator.item(1).has().title(FROZEN_YOGURT.value()); - filterDataIterator.filterDataSearchField.clearAndTypeText(DONUT.value()); + filterDataIterator.filterDataSearchField.text(DONUT.value()); filterDataIterator.item(1).has().title(DONUT.value()); filterDataIterator.filterDataSearchField.clear(); filterDataIterator.item(1).has().title(CUPCAKE.value()); @@ -110,7 +110,7 @@ public void noResultsTextDataIteratiorTest() { noResultsTextSearchField.show(); noResultsTextSearchField.clear(); noResultsTextDataIterator.elements().is().notEmpty(); - noResultsTextSearchField.clearAndTypeText("abcd"); + noResultsTextSearchField.text("abcd"); noResultsTextDataIterator.has().text(containsString("Sorry, nothing found :(")); } diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataTablesTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataTablesTests.java index bed450075e..300cc382d4 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataTablesTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/DataTablesTests.java @@ -37,7 +37,7 @@ public static void customFilterTableTest() { customFilterTable.show(); customFilterTable.searchInput().clear(); - customFilterTable.searchInput().typeText("G"); + customFilterTable.searchInput().text("G"); customFilterTable.has().size(3); customFilterTable.sortDescBy("Calories"); @@ -46,7 +46,7 @@ public static void customFilterTableTest() { .elementValue(1, 2, FROZEN_YOGURT.value()); customFilterInputField.clear(); - customFilterInputField.typeText("300"); + customFilterInputField.text("300"); customFilterTable.has() .size(2) @@ -61,7 +61,7 @@ public static void denseTableTest() { @Test(description = "Test filtering and sorting combined") public static void filterableTableTest() { filterableTable.show(); - filterableTableSearchField.clearAndTypeText(CUPCAKE_PROTEIN.value()); + filterableTableSearchField.text(CUPCAKE_PROTEIN.value()); filterableTable.clear(); filterableTable.sortDescBy("Fat (g)"); @@ -70,7 +70,7 @@ public static void filterableTableTest() { .elementName(1, ICE_CREAM_SANDWICH.value()) .elementName(2, CUPCAKE.value()); - filterableTableSearchField.clearAndTypeText(ICE_CREAM_SANDWICH.value()); + filterableTableSearchField.text(ICE_CREAM_SANDWICH.value()); filterableTable.clear(); filterableTable.has().elementName(1, "No matching records found"); @@ -222,10 +222,10 @@ public static void colorHeaderCheckboxTest() { @Test(description = "Test checks searching") public static void searchTableTest() { searchTableField.show(); - searchTableField.clearAndTypeText(DONUT.value()); + searchTableField.text(DONUT.value()); searchTable.has().cellValue(1, 1, DONUT.value()); searchTable.clear(); - searchTableField.clearAndTypeText(ECLAIR_CALORIES.value()); + searchTableField.text(ECLAIR_CALORIES.value()); searchTable.has().cellValue(1, 1, ECLAIR.value()); } @@ -293,13 +293,13 @@ public static void editDialogTableSaveTest() { editDialogTable.getColumn(1).select(3); waitCondition(() -> editDialogMenu.isDisplayed()); editDialogMenu.clear(); - editDialogMenu.typeText("New Element"); + editDialogMenu.text("New Element"); editDialogMenu.press(Keys.ENTER); editDialogTable.getColumn(6).select(1); waitCondition(() -> editDialogMenu.isDisplayed()); editDialogMenu.clear(); - editDialogMenu.typeText("146%"); + editDialogMenu.text("146%"); editDialogMenu.press(Keys.ENTER); editDialogTable.has() @@ -313,13 +313,13 @@ public static void editDialogTableCancelTest() { editDialogTable.getColumn(1).select(6); editDialogMenu.clear(); - editDialogMenu.typeText("New Element 2"); + editDialogMenu.text("New Element 2"); editDialogMenu.press(Keys.ESCAPE); editDialogTable.getColumn(6).select(1); waitCondition(() -> editDialogMenu.isDisplayed()); editDialogMenu.clear(); - editDialogMenu.typeText("146%"); + editDialogMenu.text("146%"); editDialogMenu.press(Keys.ESCAPE); editDialogTable.has() diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TimePickersTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TimePickersTests.java index 3b71a2253f..9d767179b8 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TimePickersTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TimePickersTests.java @@ -202,9 +202,9 @@ public void menuTimePickerTest() { timePickerInMenu.show(); timePickerInMenu.is().displayed(); timePickerInMenu.setTime(SEVEN_FIFTEEN_24H); - inputForMenuTimePicker.has().typedText(SEVEN_FIFTEEN_24H); + inputForMenuTimePicker.has().text(SEVEN_FIFTEEN_24H); inputForMenuTimePicker.click(); - inputForMenuTimePicker.has().typedText(SEVEN_FIFTEEN_24H); + inputForMenuTimePicker.has().text(SEVEN_FIFTEEN_24H); } @Test(description = "Test checks time changes in dialog timepicker") @@ -216,14 +216,13 @@ public void dialogTimePickerTest() { timePickerInDialog.setTime(SEVEN_FIFTEEN_24H); timePickerInDialog.has().title(SEVEN_FIFTEEN_AM); dialogForTimePicker.close("Cancel"); - inputForMenuTimePicker.is().empty(); inputForDialogTimePicker.click(); timePickerInDialog.has().title(UNSET_TIME_AM); timePickerInDialog.setTime(SEVEN_FIFTEEN_24H); timePickerInDialog.has().title(SEVEN_FIFTEEN_AM); timePickerInDialog.switchToPM(); dialogForTimePicker.close("OK"); - inputForMenuTimePicker.has().typedText(NINETEEN_FIFTEEN_24H); + inputForMenuTimePicker.has().text(NINETEEN_FIFTEEN_24H); } @Test(description = "Check that it is possible to set timepicker to numbers not present on the clock") diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TreeViewTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TreeViewTests.java index 0d97b40445..d7bb6b3c35 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TreeViewTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TreeViewTests.java @@ -169,11 +169,11 @@ public void searchAndFilterTreeViewTest() { searchFilterTreeView.show(); TreeViewNode vuetifyTree = searchFilterTreeView.node("Vuetify Human Resources"); - searchLine.typeText("Core team"); + searchLine.text("Core team"); vuetifyTree.get("Core team").has().values("John", "Kael", "Nekosaur", "Jacek", "Andrew"); searchLine.clear(); - searchLine.typeText("K"); + searchLine.text("K"); vuetifyTree.has().values("Core team", "Administrators"); vuetifyTree.get("Core team").has().values("Kael", "Nekosaur", "Jacek"); vuetifyTree.get("Administrators").has().values("Mike"); diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/InputAssert.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/InputAssert.java index d7b0222ee3..9289c7972c 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/InputAssert.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/InputAssert.java @@ -11,6 +11,7 @@ import com.epam.jdi.light.vuetify.interfaces.asserts.MessagesAssert; import com.epam.jdi.light.vuetify.interfaces.asserts.ReadOnlyAssert; import com.epam.jdi.light.vuetify.interfaces.asserts.ThemeAssert; +import org.hamcrest.Matcher; import org.hamcrest.Matchers; import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; @@ -33,60 +34,27 @@ public InputAssert enabled() { return this; } - // @todo #5048 Check the meaning of the method and if it is common for control - @JDIAction(value = "Assert that '{name}' has text in slot", isAssert = true) - public InputAssert textInSlot() { - jdiAssert(element().hasTextInSlot(), Matchers.is(true), "Input hasn't text in slot"); - return this; - } - @JDIAction(value = "Assert that '{name}' has text in slot '{0}'", isAssert = true) - public InputAssert textInSlot(String text) { - String actualTextInSlot = element().getTextInSlot(); - jdiAssert(actualTextInSlot, Matchers.equalTo(text), String.format("Actual text in slot '%s' is not equal to " + - "expected '%s'", actualTextInSlot, text)); + public InputAssert text(String text) { + jdiAssert(element().text(), Matchers.equalTo(text)); return this; } - @JDIAction(value = "Assert that '{name}' has text field", isAssert = true) - public InputAssert textField() { - jdiAssert(element().hasTextField(), Matchers.is(true), "Input hasn't text field"); + @JDIAction(value = "Assert that '{name}' matches the condition", isAssert = true) + public InputAssert text(Matcher matcher) { + jdiAssert(element().text(), matcher); return this; } @JDIAction(value = "Assert that '{name}' has text field", isAssert = true) - public InputAssert notTextField() { - jdiAssert(element().hasTextField(), Matchers.is(false), "Input text field"); + public InputAssert textInput() { + jdiAssert(element().hasInputField(), Matchers.is(true), "Input hasn't text field"); return this; } - @JDIAction(value = "Assert that '{name}' has typed text in input field", isAssert = true) - public InputAssert typedText() { - jdiAssert(element().hasTypedText(), Matchers.is(true), "Input hasn't typed text"); - return this; - } - - @JDIAction(value = "Assert that '{name}' has typed text '{0}' in input field", isAssert = true) - public InputAssert typedText(String text) { - jdiAssert(element().getTypedText(), Matchers.equalTo(text)); - return this; - } - - @JDIAction(value = "Assert that '{name}' has not typed text in input field", isAssert = true) - public InputAssert notTypedText() { - jdiAssert(element().hasTypedText(), Matchers.is(false), "Input has typed text"); - return this; - } - - @JDIAction(value = "Assert that '{name}' has empty input field", isAssert = true) - public InputAssert empty() { - jdiAssert(element().getTypedText(), Matchers.emptyString()); - return this; - } - - @JDIAction(value = "Assert that '{name}' has label", isAssert = true) - public InputAssert label() { - jdiAssert(element().hasLabel(), Matchers.is(true), "Input has no label"); + @JDIAction(value = "Assert that '{name}' has text field", isAssert = true) + public InputAssert notTextInput() { + jdiAssert(element().hasInputField(), Matchers.is(false), "Input has text field"); return this; } @@ -98,7 +66,7 @@ public InputAssert noLabel() { @JDIAction(value = "Assert that '{name}' has label '{0}'", isAssert = true) public InputAssert label(String text) { - jdiAssert(element().getLabel(), Matchers.equalTo(text)); + jdiAssert(element().label().text(), Matchers.equalTo(text)); return this; } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java index 18d0ff33f2..2dc20b7e41 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java @@ -9,6 +9,7 @@ import com.epam.jdi.light.elements.interfaces.base.HasLabel; import com.epam.jdi.light.vuetify.asserts.InputAssert; import com.epam.jdi.light.elements.interfaces.base.HasColor; +import com.epam.jdi.light.vuetify.elements.complex.TextField; import com.epam.jdi.light.vuetify.interfaces.HasDetailsHidden; import com.epam.jdi.light.vuetify.interfaces.HasMeasurement; import com.epam.jdi.light.vuetify.interfaces.HasMessages; @@ -22,19 +23,21 @@ import static com.epam.jdi.light.driver.get.DriverData.getOs; /** + * Input with text * To see an example of Input web element please visit https://v2.vuetifyjs.com/en/components/inputs/ */ public class Input extends UIBaseElement implements HasLabel, IsReadOnly, HasMessages, IsLoading, HasColor, HasTheme, HasMeasurement, IsDense, HasDetailsHidden, HasClick { - private static final String LABEL = "div label"; - private static final String INPUT = "div input"; + private static final String LABEL = ".//label"; + private static final String INPUT = ".//input"; private static final String SLOT = ".v-input__slot"; private static final String PREPEND_OUTER = ".v-input__prepend-outer"; - private static final String PREPEND_INNER = "div .v-input__prepend-inner"; + private static final String PREPEND_INNER = ".v-input__prepend-inner"; private static final String APPEND_OUTER = ".v-input__append-outer"; - private static final String APPEND_INNER = "div .v-input__append-inner"; + private static final String APPEND_INNER = ".v-input__append-inner"; + // @todo #5314 Switch is not a part of this input, it is a Switch private static final String SWITCH_SELECTION_CONTROL = "div .v-input--selection-controls__ripple"; @Override @@ -42,16 +45,13 @@ public InputAssert is() { return new InputAssert().set(this); } - private UIElement input() { - return this.find(INPUT); - } - private UIElement labelUIElement() { - return this.find(LABEL); + public UIElement input() { + return this.find(INPUT); } - public Label labelCore() { - return new Label().setCore(Label.class, labelUIElement()); + public Label label() { + return new Label().setCore(Label.class, this.find(LABEL)); } private UIElement slot() { @@ -84,44 +84,30 @@ public boolean isDisabled() { return core().hasClass("v-input--is-disabled"); } - @JDIAction("Get if '{name}' has text field") - public boolean hasTextField() { - if (input().isExist()) { - return input().attr("type").equals("text"); - } else { - return false; - } + @JDIAction("Get if '{name}' has input field") + public boolean hasInputField() { + return input().isExist(); } + // @todo #5314 Field should be cleaned before typing @JDIAction("Type text to '{name}' input field") - public void typeText(String text) { - input().sendKeys(text); - } - - @JDIAction("Clear '{name}' text field and type text to it") - public void clearAndTypeText(String text) { + public void text(String text) { this.clear(); - this.typeText(text); - } - - @JDIAction("Get if '{name}' has typed text in the text field") - public boolean hasTypedText() { - return !input().getText().isEmpty(); - } - - @JDIAction("Get {name}' typed text") - public String getTypedText() { - return input().getText(); + input().sendKeys(text); } - @JDIAction("Get if '{name}' has text in slot") - public boolean hasTextInSlot() { - return !slot().getText().isEmpty(); + @JDIAction("Type text to '{name}' input field") + public String text() { + if (input().isExist()) { + return input().text(); + } else { + return slot().text(); + } } - @JDIAction("Get '{name}' text from slot") - public String getTextInSlot() { - return slot().getText(); + @JDIAction("Type '{0}' in '{name}'") + public void type(String text) { + input().sendKeys(text); } @JDIAction("Clear '{name}' input field") @@ -139,12 +125,7 @@ public void clear() { @Override @JDIAction("Get if '{name}' has label") public boolean hasLabel() { - return labelCore().isExist() & labelCore().isDisplayed(); - } - - @JDIAction("Get '{name}' label") - public String getLabel() { - return labelUIElement().getText(); + return label().isExist() & label().isDisplayed(); } @JDIAction("Get if '{name}' is focused") @@ -158,6 +139,7 @@ public boolean hasPrependOuterIcon() { .wait(() -> this.prependOuterIcon().isExist()); } + // @todo #5314 Icon should be returned and all click methods must be removed @JDIAction("Click on '{name}' prepend outer icon") public void clickOnPrependOuterIcon() { this.prependOuterIcon().click(); From f88fbca3a1d62583f13ea89abae55b5600601057 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Tue, 9 Apr 2024 22:15:03 -0500 Subject: [PATCH 2/2] #5314 remove import --- .../java/com/epam/jdi/light/vuetify/elements/common/Input.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java index 2dc20b7e41..f4542ff723 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/common/Input.java @@ -9,7 +9,6 @@ import com.epam.jdi.light.elements.interfaces.base.HasLabel; import com.epam.jdi.light.vuetify.asserts.InputAssert; import com.epam.jdi.light.elements.interfaces.base.HasColor; -import com.epam.jdi.light.vuetify.elements.complex.TextField; import com.epam.jdi.light.vuetify.interfaces.HasDetailsHidden; import com.epam.jdi.light.vuetify.interfaces.HasMeasurement; import com.epam.jdi.light.vuetify.interfaces.HasMessages;