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