use of org.robotframework.javalib.annotation.RobotKeyword 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");
}
}
use of org.robotframework.javalib.annotation.RobotKeyword 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);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword 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);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword 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);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword 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!");
}
}
Aggregations