Search in sources :

Example 26 with ArgumentNames

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

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

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

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

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

ArgumentNames (org.robotframework.javalib.annotation.ArgumentNames)30 RobotKeyword (org.robotframework.javalib.annotation.RobotKeyword)30 JavaFXLibraryNonFatalException (javafxlibrary.exceptions.JavaFXLibraryNonFatalException)29 Node (javafx.scene.Node)10 Method (java.lang.reflect.Method)4 Window (javafx.stage.Window)4 PseudoClass (javafx.css.PseudoClass)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 BoundingBox (javafx.geometry.BoundingBox)2 Bounds (javafx.geometry.Bounds)2 JavaFXLibraryFatalException (javafxlibrary.exceptions.JavaFXLibraryFatalException)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 File (java.io.File)1