Search in sources :

Example 21 with ArgumentNames

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

the class ConvenienceKeywords method getTableRowCells.

@RobotKeyword("Returns the given table row cells in a dictionary in form of name:node pairs. \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 column" + "\nExample:\n" + "| ${row cells}= | Get Table Row Cells | \\#table-id | ${2} | \n" + "| Dictionary Should Contain Key | ${row cells} | column name | \n" + "| ${cell text}= | Get Node Text | &{row cells}[column name] | # assuming that cell is a node that has a text value |\n")
@ArgumentNames({ "table", "row" })
public Map<String, Object> getTableRowCells(Object locator, int row) {
    robotLog("INFO", "Getting cell nodes from table row: " + row);
    try {
        TableView table = (TableView) objectToNode(locator);
        Map<String, Object> cells = new HashMap<>();
        for (int i = 0; i < table.getColumns().size(); i++) {
            cells.put(getTableColumnName(table, i), mapObject(getTableRowCell(table, row, i)));
        }
        return cells;
    } catch (ClassCastException cce) {
        throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 22 with ArgumentNames

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

the class ConvenienceKeywords method findClass.

@RobotKeyword("Returns the *first* node matching the query. \n\n" + "``query`` is the Class name String to use in lookup.\n" + "\nExample:\n" + "| ${my node}= | Find | javafx.scene.control.Button | # button class |")
@ArgumentNames({ "query" })
public Object findClass(final String query) {
    try {
        Class<?> clazz = Class.forName(query);
        InstanceOfMatcher matcher = new InstanceOfMatcher(clazz);
        return mapObject(robot.lookup(matcher).query());
    } catch (Exception e) {
        robotLog("TRACE", "Problem has occurred during node lookup: " + e);
        return "";
    }
}
Also used : InstanceOfMatcher(javafxlibrary.matchers.InstanceOfMatcher) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 23 with ArgumentNames

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

the class ConvenienceKeywords method selectTabPaneTab.

@RobotKeyword("Selects the given Tab from TabPane" + "``locator`` is either a _query_ or _Object:Node_ for identifying the TabPane element, see " + "`3. Locating or specifying UI elements`. \n\n" + "``tabName`` is the name of the tab to be selected\n" + "\nExamples:\n" + "| Select Tab Pane Tab | ${Tab Pane} | tab name | \n" + "| Select Tab Pane Tab | \\#tab-id | tab name | \n")
@ArgumentNames({ "locator", "tabName" })
public void selectTabPaneTab(Object locator, String tabName) {
    robotLog("INFO", "Selecting tab: \"" + tabName + "\" from TabPane: \"" + locator + "\"");
    try {
        Node headerArea = getTabPaneHeaderArea((TabPane) objectToNode(locator));
        for (Node node : headerArea.lookupAll(".tab .tab-label")) {
            if (node instanceof Labeled) {
                String tabLabel = ((Labeled) node).getText();
                if (tabLabel != null) {
                    if (tabLabel.equals(tabName)) {
                        robotLog("TRACE", "Clicking on node: " + node);
                        robot.clickOn(node);
                        return;
                    }
                }
            }
        }
        throw new JavaFXLibraryNonFatalException("Unable to find a tab with name: " + tabName);
    } 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 24 with ArgumentNames

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

the class ConvenienceKeywords method selectContextMenuItem.

@RobotKeyword("Clicks the given item from menu\n\n" + "``item`` is the name for the Context Menu item to be clicked. This keyword clicks the first menu item that matches the given " + "item name. Search of an item is started from the last target window.\n\n" + "Example:\n" + "| Click On | \\#menu-button-id | \n" + "| Select Context Menu Item | menu item name |")
@ArgumentNames({ "item" })
public void selectContextMenuItem(String item) {
    List<Window> windows = robot.listTargetWindows();
    ListIterator li = windows.listIterator(windows.size());
    while (li.hasPrevious()) {
        for (Node node : robot.rootNode((Window) li.previous()).lookupAll(".menu-item")) {
            if (getMenuItemText(node).equals(item)) {
                robot.clickOn(node, Motion.HORIZONTAL_FIRST);
                return;
            }
        }
    }
    throw new JavaFXLibraryNonFatalException("unable to find menu item: " + item);
}
Also used : Window(javafx.stage.Window) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Node(javafx.scene.Node) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 25 with ArgumentNames

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

the class ConvenienceKeywords method getSelectedTabPaneTab.

@RobotKeyword("Returns the selected TabPane Tab as a dictionary entry in form of 'name : Node' pair.\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" + "| ${tab}= | Get Tab Pane Selected Tab | \\#pane-id | \n" + "| Dictionary Should contain Key | ${tab} | tab name | \n")
@ArgumentNames({ "locator" })
public Map<String, Object> getSelectedTabPaneTab(Object locator) {
    robotLog("INFO", "Getting the selected tab from TabPane: " + locator);
    Map<String, Object> tab = new HashMap<>();
    try {
        TabPane tabPane = (TabPane) objectToNode(locator);
        tab.put(getSelectedTabName(tabPane), mapObject(getSelectedTab(tabPane)));
        return tab;
    } catch (ClassCastException cce) {
        throw new JavaFXLibraryNonFatalException("Given locator: \"" + locator + "\" could not be handled as TabPane!", cce);
    }
}
Also used : 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