Search in sources :

Example 31 with RobotKeyword

use of org.robotframework.javalib.annotation.RobotKeyword 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 32 with RobotKeyword

use of org.robotframework.javalib.annotation.RobotKeyword 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 33 with RobotKeyword

use of org.robotframework.javalib.annotation.RobotKeyword 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 34 with RobotKeyword

use of org.robotframework.javalib.annotation.RobotKeyword 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

RobotKeyword (org.robotframework.javalib.annotation.RobotKeyword)34 JavaFXLibraryNonFatalException (javafxlibrary.exceptions.JavaFXLibraryNonFatalException)33 ArgumentNames (org.robotframework.javalib.annotation.ArgumentNames)30 Node (javafx.scene.Node)10 JavaFXLibraryFatalException (javafxlibrary.exceptions.JavaFXLibraryFatalException)5 Method (java.lang.reflect.Method)4 Window (javafx.stage.Window)4 PseudoClass (javafx.css.PseudoClass)3 BoundingBox (javafx.geometry.BoundingBox)3 Scene (javafx.scene.Scene)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 ObservableList (javafx.collections.ObservableList)2 Bounds (javafx.geometry.Bounds)2 Rectangle2D (javafx.geometry.Rectangle2D)2 InstanceOfMatcher (javafxlibrary.matchers.InstanceOfMatcher)2 ListViewSkin (com.sun.javafx.scene.control.skin.ListViewSkin)1 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1