Skip to content

Commit b401126

Browse files
committed
Fix Move To keyword to handle not foundable queries properly, added related test, fixes #39
1 parent 793e3a7 commit b401126

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/main/java/javafxlibrary/keywords/Keywords/MoveRobot.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ public class MoveRobot extends TestFxAdapter {
4949
@ArgumentNames({ "locator", "motion=DIRECT" })
5050
public FxRobotInterface moveTo(Object locator, String motion) {
5151
RobotLog.info("Moving to target \"" + locator + "\" using motion: \"" + getMotion(motion) + "\"");
52-
53-
if (locator instanceof String)
52+
if (locator instanceof String) {
53+
String originalLocator = (String) locator;
5454
locator = new Finder().find((String) locator);
55+
if(locator==null) {
56+
throw new JavaFXLibraryNonFatalException("Unable to move as locator \"" + originalLocator + "\" not found!");
57+
} else {
58+
RobotLog.info("Locator at this point: " + locator);
59+
}
60+
}
5561

5662
Method method = MethodUtils.getMatchingAccessibleMethod(robot.getClass(), "moveTo", locator.getClass(), Motion.class);
5763

@@ -73,7 +79,7 @@ public FxRobotInterface moveTo(Object locator, String motion) {
7379
public FxRobotInterface moveBy(int x, int y, String motion) {
7480
try {
7581
RobotLog.info("Moving by [" + x + ", " + y + "] using motion: \"" + motion + "\"");
76-
return robot.moveBy((double) x, (double) y, HelperFunctions.getMotion(motion));
82+
return robot.moveBy(x, y, HelperFunctions.getMotion(motion));
7783
} catch (Exception e) {
7884
if (e instanceof JavaFXLibraryNonFatalException)
7985
throw e;
@@ -94,7 +100,7 @@ public FxRobotInterface moveBy(int x, int y, String motion) {
94100
public FxRobotInterface moveToCoordinates(int x, int y, String motion) {
95101
try {
96102
RobotLog.info("Moving to coordinates: [" + x + ", " + y + "] using motion: \"" + motion + "\"");
97-
return robot.moveTo((double) x, (double) y, HelperFunctions.getMotion(motion));
103+
return robot.moveTo(x, y, HelperFunctions.getMotion(motion));
98104
} catch (Exception e) {
99105
if (e instanceof JavaFXLibraryNonFatalException)
100106
throw e;

src/test/robotframework/acceptance/MoveRobotTest.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ Move To Window
8585
${Y} Convert To Integer ${Y}
8686
Verify String id=locationLabel ${X} | ${Y}
8787
88+
Move To Nonexistent Location
89+
[Tags] smoke
90+
Run Keyword And Expect Error Unable to move as locator "css=\#rectangleNOTfound" not found! Move To css=\#rectangleNOTfound
91+
8892
*** Keywords ***
8993
Setup all tests
9094
Import JavaFXLibrary

0 commit comments

Comments
 (0)