From c48e7f22321bb259d798ff7964f935706d71ac16 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Sat, 13 Apr 2024 10:24:46 -0500 Subject: [PATCH] #5320 Fix TextField --- .../tests/complex/TextFieldsTests.java | 27 ++++++++++--------- .../vuetify/asserts/TextFieldAssert.java | 18 +++---------- .../vuetify/elements/complex/TextField.java | 6 +---- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TextFieldsTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TextFieldsTests.java index 2b60706850..b877a2cfbf 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TextFieldsTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/TextFieldsTests.java @@ -58,27 +58,27 @@ public void before() { public void counterTextFieldTest() { String defText = "Preliminary report"; TextField regularCounterField = counterTextField.get(1); - regularCounterField.has().labelText("Regular"); + regularCounterField.has().label("Regular"); regularCounterField.setText(defText); - regularCounterField.has().counter(18, 25); + regularCounterField.has().counter("18 / 25"); regularCounterField.click(); regularCounterField.has().messageText("This field uses counter prop"); TextField customCountPropField = counterTextField.get(3); - customCountPropField.has().labelText("Custom counter from prop"); + customCountPropField.has().label("Custom counter from prop"); customCountPropField.has().text(defText); - customCountPropField.has().counter(2, 5); + customCountPropField.has().counter("2 / 5"); customCountPropField.click(); customCountPropField.messages().get(1).has().text("This field counts words instead of characters"); TextField customCountSlotField = counterTextField.get(4); customCountSlotField.label().is().text("Custom counter from slot"); customCountSlotField.has().text(defText); - customCountSlotField.has().counter(2, 5); + customCountSlotField.has().counter("2 / 5"); customCountSlotField.click(); customCountSlotField.has().messageText("This field counts words instead of characters"); TextField limitExcField = counterTextField.get(2); - limitExcField.is().labelText("Limit exceeded"); - limitExcField.has().counter(50, 25); + limitExcField.is().label("Limit exceeded"); + limitExcField.has().counter("50 / 25"); limitExcField.click(); limitExcField.has().messageText("This field uses maxlength attribute"); customCountSlotField.click(); @@ -88,8 +88,8 @@ public void counterTextFieldTest() { regularCounterField.has().text(""); customCountPropField.has().text(""); customCountSlotField.has().text(""); - regularCounterField.has().counter(0, 25); - customCountSlotField.has().counter(1, 5); + regularCounterField.has().counter("0 / 25"); + customCountSlotField.has().counter("1 / 5"); } @@ -259,12 +259,13 @@ public void hintTextFieldTest() { @Test (description = "Test checks validation fields : rules (func), validate-on-blur (y/n)") public void validationTextFieldTest() { String maxLengthString = "abcdeabcdeabcdeabcde"; + String format = String.format("%d / 20", maxLengthString.length()); validationTextField.get(1).setText(maxLengthString); validationTextField.get(1).is().text(maxLengthString); - validationTextField.get(1).is().counter(maxLengthString.length(), 20); + validationTextField.get(1).is().counter(format); validationTextField.get(1).setText(maxLengthString + "abcd"); validationTextField.get(1).is().text(maxLengthString); - validationTextField.get(1).is().counter(maxLengthString.length(), 20); + validationTextField.get(1).is().counter(format); validationTextField.get(2).setText("email"); validationTextField.get(2).has().errorMessage("Invalid e-mail."); @@ -313,7 +314,7 @@ public void iconSlotsTextFieldTest() { // @todo #5048 Fix the test to not use the locator and check the content of an element @Test (description = "Test checks text field label and it's text") - public void labelTextFieldTest() { + public void labelFieldTest() { labelTextField.has().label(); labelTextField.label().has().text("What about icon here?"); labelTextField.label().find("./i").isDisplayed(); @@ -368,7 +369,7 @@ public void loadingTextField() { TextField loadedTextField = darkTextField.get(1); loadingTextField1.show(); loadingTextField1.is().loading(); - loadingTextField1.has().loaderHeightPx(2); + loadingTextField1.loader().has().height(2); loadedTextField.show(); loadedTextField.is().loaded(); } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/TextFieldAssert.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/TextFieldAssert.java index e8fc910624..89c20bc278 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/TextFieldAssert.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/TextFieldAssert.java @@ -65,7 +65,6 @@ public TextFieldAssert notFocused() { @JDIAction(value = "Assert that '{name}' text type is '{0}'", isAssert = true) public TextFieldAssert textType(String textType) { - String actualTextType = element().getTextType(); jdiAssert(element().getTextType(), Matchers.equalTo(textType)); return this; } @@ -92,19 +91,14 @@ public TextFieldAssert placeholder(String placeholder) { return this; } - // @todo #5048 Change the implementation to check real counter content without any manipulation @JDIAction(value = "Assert that '{name}' current counter is '{0}' and max counter is '{1}'", isAssert = true) - public TextFieldAssert counter(int currentCounter, int maxCounter) { - String[] counter = element().counter().text().replaceAll("\\s", "").split("/"); - jdiAssert(Integer.parseInt(counter[0]), Matchers.equalTo(currentCounter), String.format("Actual current counter " + - "'%s' is not equal to expected '%s'", counter[0], currentCounter)); - jdiAssert(Integer.parseInt(counter[1]), Matchers.equalTo(maxCounter), String.format("Actual max counter '%s' is " + - "not equal to expected '%s'", counter[1], maxCounter)); + public TextFieldAssert counter(String counter) { + jdiAssert(element().counter().text(), Matchers.equalTo(counter)); return this; } @JDIAction(value = "Assert that '{name}' has label {0}", isAssert = true) - public TextFieldAssert labelText(String label) { + public TextFieldAssert label(String label) { jdiAssert(element().labelText(), Matchers.is(label)); return this; } @@ -154,10 +148,4 @@ public TextFieldAssert notAutofocus() { jdiAssert(element().isAutofocus(), Matchers.is(false), "TextField is autofocus"); return this; } - - @JDIAction(value = "Assert that '{name}' has loader height {0}", isAssert = true) - public TextFieldAssert loaderHeightPx(int height) { - jdiAssert(element().getLoaderHeight(), Matchers.equalTo(height)); - return this; - } } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TextField.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TextField.java index 6ef6a9b8c7..5dc32d0dc5 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TextField.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TextField.java @@ -110,6 +110,7 @@ public List messages() { return details().finds(messageLocator); } + // @todo #5320 Check this method, not clear why should we have external locator @Override @JDIAction("Get '{name}' messages text by locator '{0}'") public List messagesText(String locator) { @@ -312,11 +313,6 @@ public ProgressLinear loader() { return new ProgressLinear().setCore(ProgressLinear.class, core().find(loaderLocator)); } - @JDIAction("Get '{name}' loader height") - public int getLoaderHeight() { - return Integer.parseInt(core().find(loaderLocator).css("height").replace("px", "")); - } - @Override public TextFieldAssert is() { return new TextFieldAssert().set(this);