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!");
}
}
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 "";
}
}
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);
}
}
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);
}
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);
}
}
Aggregations