use of org.robotframework.javalib.annotation.RobotKeyword in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method getTableColumnValues.
@RobotKeyword("Returns list of values of the given table column.\n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the TableView element, see " + "`3. Locating or specifying UI elements`. \n\n" + "``column`` Integer value for the column")
@ArgumentNames({ "table", "column" })
public List<Object> getTableColumnValues(Object locator, int column) {
try {
TableView table = (TableView) objectToNode(locator);
ObservableList items = table.getItems();
List<Object> values = new ArrayList<>();
TableColumn tableColumn = (TableColumn) table.getColumns().get(column);
if (tableColumn.getText() != null)
robotLog("INFO", "Getting values from column " + tableColumn.getText());
else
robotLog("INFO", "Getting values from column using index " + column);
for (Object item : items) {
Object value = tableColumn.getCellObservableValue(item).getValue();
values.add(mapObject(value));
}
return values;
} catch (IndexOutOfBoundsException e) {
throw new JavaFXLibraryNonFatalException("Out of table bounds: " + e.getMessage());
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Couldn't get column values: " + e.getMessage());
}
}
use of org.robotframework.javalib.annotation.RobotKeyword in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method findAllWithPseudoClass.
@RobotKeyword("Returns *all* nodes matching query AND given pseudo-class state. \r\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" + "``pseudo`` is a String value specifying pseudo class value.\n\n" + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and " + "keyword returns null in case lookup returns nothing.\n\n" + "\nExample:\n" + "| ${my node}= | Find All With Pseudo Class | .check-box-tree-cell .check-box | selected | \n")
@ArgumentNames({ "query", "pseudo", "failIfNotFound=" })
public List<Object> findAllWithPseudoClass(String query, String pseudo, boolean failIfNotFound) {
robotLog("INFO", "Trying to find all nodes with query: \"" + query + "\" that has pseudoclass state as: \"" + pseudo + "\", failIfNotFound= \"" + Boolean.toString(failIfNotFound) + "\"");
try {
Set<Node> nodes = robot.lookup(query).queryAll();
Set<Node> matches = nodes.stream().filter(n -> n.getPseudoClassStates().stream().map(PseudoClass::getPseudoClassName).anyMatch(pseudo::contains)).collect(Collectors.toSet());
return mapObjects(matches);
} catch (JavaFXLibraryNonFatalException e) {
if (failIfNotFound)
throw e;
return Collections.emptyList();
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Find all with pseudo class operation failed for query: \"" + query + "\" and pseudo: \"" + pseudo + "\"", e);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword 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.RobotKeyword in project JavaFXLibrary by eficode.
the class ApplicationLauncher method logSystemProperties.
@RobotKeyword("Prints all system properties that has been set with *Set System Property* -keyword\n")
public void logSystemProperties() {
try {
Properties p = System.getProperties();
Enumeration keys = p.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = (String) p.get(key);
HelperFunctions.robotLog("INFO", key + "=" + value);
}
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to log system properties", e);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword in project JavaFXLibrary by eficode.
the class ApplicationLauncher method logApplicationClassPath.
@RobotKeyword("Logs current classpath content")
public void logApplicationClassPath() {
try {
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader) cl).getURLs();
HelperFunctions.robotLog("INFO", "Printing out classpaths: \n");
for (URL url : urls) {
HelperFunctions.robotLog("INFO", url.getFile());
}
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to log application classpaths", e);
}
}
Aggregations