Skip to content

Commit

Permalink
Merge pull request #5440 from jdi-testing/5314
Browse files Browse the repository at this point in the history
#5314 clear Inputs control from notclear methods
  • Loading branch information
pnatashap authored Apr 10, 2024
2 parents 5768e75 + f88fbca commit c4780fe
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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")
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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 :("));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)
Expand All @@ -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)");
Expand All @@ -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");
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> 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;
}

Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit c4780fe

Please sign in to comment.