Search in sources :

Example 41 with JavaFXLibraryNonFatalException

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 42 with JavaFXLibraryNonFatalException

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 43 with JavaFXLibraryNonFatalException

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Clipboard(java.awt.datatransfer.Clipboard) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) StringSelection(java.awt.datatransfer.StringSelection) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 44 with JavaFXLibraryNonFatalException

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 45 with JavaFXLibraryNonFatalException

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Aggregations

JavaFXLibraryNonFatalException (javafxlibrary.exceptions.JavaFXLibraryNonFatalException)46 RobotKeyword (org.robotframework.javalib.annotation.RobotKeyword)32 ArgumentNames (org.robotframework.javalib.annotation.ArgumentNames)28 Node (javafx.scene.Node)15 Method (java.lang.reflect.Method)6 TimeoutException (java.util.concurrent.TimeoutException)6 ConditionTimeoutException (org.awaitility.core.ConditionTimeoutException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 PseudoClass (javafx.css.PseudoClass)5 Window (javafx.stage.Window)5 Scene (javafx.scene.Scene)4 JavaFXLibraryFatalException (javafxlibrary.exceptions.JavaFXLibraryFatalException)4 BoundingBox (javafx.geometry.BoundingBox)3 Image (javafx.scene.image.Image)3 TableViewSkin (com.sun.javafx.scene.control.skin.TableViewSkin)2 VirtualFlow (com.sun.javafx.scene.control.skin.VirtualFlow)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 JarFile (java.util.jar.JarFile)2 ObservableList (javafx.collections.ObservableList)2