Skip to content

Commit 8974446

Browse files
committed
Replace method call with KeyboardRobot input in Clear Text Input
1 parent 133a171 commit 8974446

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import javafx.stage.Stage;
3434
import javafx.stage.Window;
3535
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
36+
import javafxlibrary.keywords.Keywords.ClickRobot;
37+
import javafxlibrary.keywords.Keywords.KeyboardRobot;
3638
import javafxlibrary.matchers.InstanceOfMatcher;
3739
import javafxlibrary.utils.HelperFunctions;
3840
import javafxlibrary.utils.RobotLog;
@@ -498,8 +500,9 @@ public String getNodeText(Object locator) {
498500
}
499501
}
500502

501-
// TODO: Deprecate
502-
@RobotKeyword("Returns height value of the node. \n\n"
503+
@Deprecated
504+
@RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n"
505+
+ "Returns height value of the node. \n\n"
503506
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
504507
+ "`3. Locating or specifying UI elements`. \n\n")
505508
@ArgumentNames({ "locator" })
@@ -1068,7 +1071,6 @@ public Object getSelectedDatePickerDate(Object locator) {
10681071
}
10691072
}
10701073

1071-
// TODO: Remove
10721074
@RobotKeyword("Clears the text value of given TextInputControl\n\n"
10731075
+ "``locator`` is either a _query_ or _TextInputControl_ object. For identifying the element, see "
10741076
+ "`3. Locating or specifying UI elements`. \n\n"
@@ -1077,10 +1079,12 @@ public Object getSelectedDatePickerDate(Object locator) {
10771079
@ArgumentNames({ "locator" })
10781080
public void clearTextInput(Object locator) {
10791081
try {
1080-
TextInputControl input = (TextInputControl) objectToNode(locator);
1081-
input.clear();
1082-
} catch (ClassCastException cce) {
1083-
throw new JavaFXLibraryNonFatalException("Unable to handle target as TextInputControl!");
1082+
TextInputControl textInputControl = (TextInputControl) objectToNode(locator);
1083+
new ClickRobot().clickOn(textInputControl);
1084+
new KeyboardRobot().selectAll();
1085+
robot.push(KeyCode.BACK_SPACE);
1086+
} catch (ClassCastException e) {
1087+
throw new JavaFXLibraryNonFatalException("Target is not an instance of TextInputControl!");
10841088
}
10851089
}
10861090

0 commit comments

Comments
 (0)