use of org.robotframework.javalib.annotation.RobotKeyword 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.RobotKeyword 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.RobotKeyword 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.RobotKeyword 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);
}
}
use of org.robotframework.javalib.annotation.RobotKeyword in project JavaFXLibrary by eficode.
the class ClickRobot method clickOnCoordinates.
@RobotKeyword("Moves mouse directly to the given coordinates and clicks the primary mouse button\n\n" + "``x`` and ``y`` defines the coordinates as integer values. \n\n" + "Optional argument ``motion`` defines how mouse pointer is moved to target. Defaults to _DIRECT_.")
@ArgumentNames({ "x", "y", "motion=DIRECT" })
public FxRobotInterface clickOnCoordinates(int x, int y, String motion) {
robotLog("INFO", "Clicking on coordinates x=\"" + Integer.toString(x) + "\"" + ", y=\"" + Integer.toString(y) + "\"" + " and motion=\"" + motion + "\"");
checkClickLocation(x, y);
try {
return robot.clickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY);
} catch (Exception e) {
if (e instanceof JavaFXLibraryNonFatalException) {
throw e;
}
throw new JavaFXLibraryNonFatalException("Unable to click on coordinates: " + Integer.toString(x) + " " + Integer.toString(y), e);
}
}
Aggregations