use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.
the class ApplicationLauncher method launchJavafxApplication.
@RobotKeyword("Launches JavaFX application with the given arguments.\n\n" + "``appName`` is the name of the application to launch. \n\n" + "``appArgs`` is a list of arguments to be passed for the application. \n\n" + "Example:\n" + "| Launch JavaFX Application | _javafxlibrary.testapps.MenuApp_ |\n")
@ArgumentNames({ "appName", "*args" })
public void launchJavafxApplication(String appName, String... appArgs) {
try {
HelperFunctions.robotLog("INFO", "Starting application:" + appName);
createNewSession(appName, appArgs);
HelperFunctions.robotLog("INFO", "Application: " + appName + " started.");
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to launch application: " + appName, e);
}
}
use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method getNodeImageUrl.
@RobotKeyword("Returns image name and path of the node. \n\n" + "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see " + "`3. Locating or specifying UI elements`. \n\n" + "Returns full image path by subsequently calling impl_getUrl -method. \n\n" + "Note, impl_getUrl -method is deprecated! Support for this method will be removed from Java in the future.")
@ArgumentNames({ "node" })
public String getNodeImageUrl(Object locator) {
Node node = objectToNode(locator);
robotLog("INFO", "Getting image url from node: \"" + node.toString() + "\"");
try {
Method[] methods = node.getClass().getMethods();
for (Method m : methods) {
if (m.getName().equals("getImage") && m.getParameterCount() == 0) {
robotLog("TRACE", "Method getImage() found. Invoking it on node: \"" + node.toString() + "\"");
try {
Object result = m.invoke(node, null);
Image image = (Image) result;
robotLog("TRACE", "Calling deprecated method impl_getUrl() for image: \"" + image.toString() + "\"");
return image.impl_getUrl();
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Problem calling method: .getImage(): " + e.getMessage(), e);
}
}
}
throw new JavaFXLibraryNonFatalException("Get node image url failed for node: \"" + node.toString() + "\". Element has no method impl_getUrl()");
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException)
throw e;
throw new JavaFXLibraryNonFatalException("Unable to get node image url for node: \"" + node.toString() + "\"", e);
}
}
use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method switchWindow.
/*
* TODO: Switching between test applications using CMD + TAB doesn't work on Mac
* cmd + tab moves between top level applications and multiple JavaFX applications launched by the testing framework
* are bundled under a single tab named Java.
*/
@RobotKeyword("Presses ALT/CMD + TAB for the given amount of times. \n\n" + "``switchAmount`` is an Integer value and specifies how many switches will be made in total")
@ArgumentNames({ "switchAmount" })
public void switchWindow(int switchAmount) {
robotLog("INFO", "Switching window for: \"" + Integer.toString(switchAmount) + "\" times.");
try {
if (isMac()) {
robot.press(KeyCode.META);
} else {
robot.press(KeyCode.ALT);
}
for (int i = 0; i < switchAmount; i++) {
robot.push(KeyCode.TAB);
}
robot.release(KeyCode.META);
robot.release(KeyCode.ALT);
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to switch window.", e);
}
}
use of org.robotframework.javalib.annotation.ArgumentNames in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method getTableColumnCells.
@RobotKeyword("Returns a list of *visible* cells(Nodes) 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> getTableColumnCells(Object locator, int column) {
try {
TableView table = (TableView) objectToNode(locator);
List<Object> columnCells = new ArrayList<>();
VirtualFlow<?> vf = (VirtualFlow<?>) ((TableViewSkin<?>) table.getSkin()).getChildren().get(1);
for (int i = vf.getFirstVisibleCell().getIndex(); i < vf.getLastVisibleCell().getIndex() + 1; i++) {
robotLog("INFO", "index number: " + Integer.toString(i));
columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column)));
}
return mapObjects(columnCells);
} 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 getTableRowValues.
@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 List<Object> getTableRowValues(Object locator, int rowNumber) {
robotLog("INFO", "Getting values from table row: " + rowNumber);
try {
TableView table = (TableView) objectToNode(locator);
Object row = table.getItems().get(rowNumber);
List<Object> values = new ArrayList<>();
for (Object tableColumn : table.getColumns()) {
values.add(((TableColumn) tableColumn).getCellObservableValue(row).getValue());
}
return values;
} catch (ClassCastException cce) {
throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
}
}
Aggregations