use of javafxlibrary.exceptions.JavaFXLibraryNonFatalException in project JavaFXLibrary by eficode.
the class ClickRobot method clickOnCoordinates.
@RobotKeyword("Moves mouse directly to the given coordinates and clicks the primary mouse button\n\n" + "``x`` and ``y`` defines the coordinates as integer values. \n\n" + "Optional argument ``motion`` defines how mouse pointer is moved to target. Defaults to _DIRECT_.")
@ArgumentNames({ "x", "y", "motion=DIRECT" })
public FxRobotInterface clickOnCoordinates(int x, int y, String motion) {
robotLog("INFO", "Clicking on coordinates x=\"" + Integer.toString(x) + "\"" + ", y=\"" + Integer.toString(y) + "\"" + " and motion=\"" + motion + "\"");
checkClickLocation(x, y);
try {
return robot.clickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY);
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException) {
throw e;
}
throw new JavaFXLibraryNonFatalException("Unable to click on coordinates: " + Integer.toString(x) + " " + Integer.toString(y), e);
}
}
use of javafxlibrary.exceptions.JavaFXLibraryNonFatalException in project JavaFXLibrary by eficode.
the class KeyboardRobot method pushManyTimes.
@RobotKeyword("Pushes a given key/key combination multiple times.\n\n" + "``times`` defines how many times to push\n" + "``keys`` is the key combination to push, see a list of different KeyCodes in `5. Used ENUMs`. \n\n" + "\nExample:\n" + "| Push Many Times | 2 | LEFT | \n" + "| Push Many Times | 5 | SHIFT | X |\n")
@ArgumentNames({ "times", "*keys" })
public void pushManyTimes(int times, String... keys) {
robotLog("INFO", "Pushing combination: \"" + Arrays.asList(keys) + "\" for \"" + Integer.toString(times) + "\" times.");
try {
for (int i = 0; i < times; i++) {
robot.push(getKeyCode(keys));
sleepFor(50);
}
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException)
throw e;
throw new JavaFXLibraryNonFatalException("Unable to push: " + Arrays.asList(keys), e);
}
}
use of javafxlibrary.exceptions.JavaFXLibraryNonFatalException in project JavaFXLibrary by eficode.
the class KeyboardRobot method writeFast.
@RobotKeyword("Writes a given text to system clipboard and pastes the content to active element.\n\n" + "``text`` is the text characters to write\n" + "\nExample: \n" + "| Write Fast | Robot Framework | \n")
@ArgumentNames({ "text" })
public void writeFast(String text) {
try {
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection testData = new StringSelection(text);
c.setContents(testData, testData);
if (isMac())
robot.push(KeyCode.META, KeyCode.V).sleep(100);
else
robot.push(KeyCode.CONTROL, KeyCode.V).sleep(100);
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException)
throw e;
throw new JavaFXLibraryNonFatalException("Unable to write text using copy/paste method.", e);
}
}
use of javafxlibrary.exceptions.JavaFXLibraryNonFatalException in project JavaFXLibrary by eficode.
the class ScreenCapturing method saveImageAs.
@RobotKeyword("Saves given image to given location\n\n" + "``image`` is the target _Object:Image_ to be saved\n" + "``path`` is the target location where image will be saved")
@ArgumentNames({ "image", "path" })
public void saveImageAs(Image image, String path) {
try {
robotLog("INFO", "Saving image \"" + image.toString() + "\" to path \"" + path + "\"");
robotContext.getCaptureSupport().saveImage(image, Paths.get(path));
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException)
throw e;
throw new JavaFXLibraryNonFatalException("Unable to save image.", e);
}
}
use of javafxlibrary.exceptions.JavaFXLibraryNonFatalException in project JavaFXLibrary by eficode.
the class ScrollRobot method scrollVertically.
@RobotKeyword("Scrolls vertically by amount (in terms of ticks of a mouse wheel) in given direction.\n\n" + "``amount`` is the number of scroll ticks, defaults to 1. \n\n" + "``direction`` specifies whether to scroll UP or DOWN. \n\n" + "\nExample:\n" + "| Move To | ${some node} | \n" + "| Scroll Vertically | DOWN | 25 | \n")
@ArgumentNames({ "direction", "amount=1" })
public void scrollVertically(String direction, int amount) {
try {
HelperFunctions.robotLog("INFO", "Scrolling \"" + direction + "\" by \"" + Integer.toString(amount) + "\" ticks.");
robot.scroll(amount, HelperFunctions.getVerticalDirection(direction));
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException)
throw e;
throw new JavaFXLibraryNonFatalException("Unable to scroll vertically to direction: \"" + direction + "\"", e);
}
}
Aggregations