Search in sources :

Example 16 with ArgumentNames

use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.

the class ApplicationLauncher method setToClasspath.

@RobotKeyword("Loads given path to classpath.\n\n" + "``path`` is the path to add.\n\n" + "If directory path has asterisk(*) after directory separator all jar files are added from directory.\n" + "\nExample:\n" + "| Set To Classpath | C:${/}users${/}my${/}test${/}folder | \n" + "| Set To Classpath | C:${/}users${/}my${/}test${/}folder${/}* | \n")
@ArgumentNames({ "path" })
public void setToClasspath(String path) {
    if (path.endsWith("*")) {
        path = path.substring(0, path.length() - 1);
        HelperFunctions.robotLog("INFO", "Adding all jars from directory: " + path);
        try {
            File directory = new File(path);
            File[] fileList = directory.listFiles();
            for (File file : fileList) {
                if (file.getName().endsWith(".jar"))
                    _addPathToClassPath(file.getAbsolutePath());
            }
        } catch (NullPointerException e) {
            throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e);
        }
    } else {
        _addPathToClassPath(path);
    }
}
Also used : JavaFXLibraryFatalException(javafxlibrary.exceptions.JavaFXLibraryFatalException) File(java.io.File) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 17 with ArgumentNames

use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.

the class ConvenienceKeywords method getTableCellValue.

@RobotKeyword("Returns the value of cell in the given location\n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the TableView element, see " + "`3. Locating or specifying UI elements`. \n\n" + "``row`` Integer value for the row\n\n" + "``column`` Integer value for the column")
@ArgumentNames({ "table", "row", "column" })
public Object getTableCellValue(Object locator, int row, int column) {
    try {
        TableView table = (TableView) objectToNode(locator);
        Object item = table.getItems().get(row);
        TableColumn col = (TableColumn) table.getColumns().get(column);
        Object value = col.getCellObservableValue(item).getValue();
        return HelperFunctions.mapObject(value);
    } catch (ClassCastException cce) {
        throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
    } catch (IndexOutOfBoundsException e) {
        throw new JavaFXLibraryNonFatalException("Out of table bounds: " + e.getMessage());
    } catch (Exception e) {
        throw new JavaFXLibraryNonFatalException("Couldn't get table cell value");
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 18 with ArgumentNames

use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.

the class ConvenienceKeywords method getTabPaneTabs.

@RobotKeyword("Returns a dictionary containing key:value pairs for each tab name and tab content(Node).\n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the TabPane element, see " + "`3. Locating or specifying UI elements`. \n\n" + "\nExample:\n" + "| ${tabs}= | Get Tab pane Tabs | \\#tab-pane-id | \n" + "| Dictionary Should Contain Key | ${tabs} | tab name | \n")
@ArgumentNames({ "locator" })
public Map<String, Object> getTabPaneTabs(Object locator) {
    robotLog("INFO", "Getting a dictionary for all tabs in TabPane: " + locator);
    try {
        TabPane tabPane = (TabPane) objectToNode(locator);
        Map<String, Object> tabs = new HashMap<>();
        int i = tabPane.getTabs().size() - 1;
        for (Node node : tabPane.getChildrenUnmodifiable()) {
            if (node.getStyleClass().contains("tab-content-area")) {
                tabs.put(getTabHeaderText(tabPane, i), mapObject(node));
                i--;
            }
        }
        return tabs;
    } catch (ClassCastException cce) {
        throw new JavaFXLibraryNonFatalException("Given locator: \"" + locator + "\" could not be handled as TabPane!", cce);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Node(javafx.scene.Node) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 19 with ArgumentNames

use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.

the class ConvenienceKeywords method getNodeChildrenByClassName.

// TODO: Should this be deleted? Find All From Node has the same functionality
@RobotKeyword("Returns *all* descendant nodes of given node matching the given Java class name. \n\n" + "``locator`` is either a _query_ or _Object_ for node whose children will be queried, see " + "`3. Locating or specifying UI elements`. \n\n" + "``className`` is the Java class name to look for.\n" + "\nExample:\n" + "| ${panes}= | Get Node Children By Class Name | ${some node} | BorderPane | \n" + "Returns an empty list if none is found. \n")
@ArgumentNames({ "node", "className" })
public Set<Object> getNodeChildrenByClassName(Object locator, String className) {
    Node node = objectToNode(locator);
    robotLog("INFO", "Getting node: \"" + node.toString() + "\" children by class name: \"" + className + "\"");
    try {
        Set<Object> keys = new HashSet<Object>();
        Set childNodes = node.lookupAll("*");
        Iterator iter = childNodes.iterator();
        while (iter.hasNext()) {
            Node childNode = (Node) iter.next();
            if (childNode.getClass().getSimpleName().equals(className)) {
                robotLog("TRACE", "Classname: \"" + className + "\" found: \"" + childNode.toString() + "\"");
                keys.add(mapObject(childNode));
            }
        }
        return keys;
    } catch (Exception e) {
        if (e instanceof JavaFXLibraryNonFatalException)
            throw e;
        throw new JavaFXLibraryNonFatalException("Unable to get node children for node: \"" + node.toString() + "\" with class name: " + className, e);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Node(javafx.scene.Node) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 20 with ArgumentNames

use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.

the class ConvenienceKeywords method listNodeMethods.

@RobotKeyword("Lists methods available for given node.\n" + "``node`` is the Object:Node which methods to list, see `3.2 Using objects`. \n\n" + "When working with custom components you may use this keyword to discover methods you can call " + "with `Call Method` keyword.\n\n" + "Example:\n" + "| List Component Methods | ${my node} |\n")
@ArgumentNames({ "node" })
public String[] listNodeMethods(Node node) {
    robotLog("INFO", "Listing all available methods for node: \"" + node.toString() + "\"");
    try {
        Class klass = node.getClass();
        ArrayList<String> list = new ArrayList<String>();
        System.out.println("*INFO*");
        while (klass != null) {
            String name = String.format("\n*%s*\n", klass.getName());
            System.out.println(name);
            list.add(name);
            for (Method m : klass.getDeclaredMethods()) {
                String entry = getMethodDescription(m);
                System.out.println(entry);
                list.add(entry);
            }
            klass = klass.getSuperclass();
        }
        return list.toArray(new String[list.size()]);
    } catch (Exception e) {
        throw new JavaFXLibraryNonFatalException("Listing node methods failed.", e);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) PseudoClass(javafx.css.PseudoClass) Method(java.lang.reflect.Method) 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