Search in sources :

Example 16 with RobotKeyword

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());
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) ObservableList(javafx.collections.ObservableList) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 17 with RobotKeyword

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);
    }
}
Also used : RobotKeywords(org.robotframework.javalib.annotation.RobotKeywords) java.util(java.util) ListViewSkin(com.sun.javafx.scene.control.skin.ListViewSkin) PseudoClass(javafx.css.PseudoClass) javafx.scene.control(javafx.scene.control) BoundingBox(javafx.geometry.BoundingBox) HelperFunctions(javafxlibrary.utils.HelperFunctions) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames) Parent(javafx.scene.Parent) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) InstanceOfMatcher(javafxlibrary.matchers.InstanceOfMatcher) TestFxAdapter(javafxlibrary.utils.TestFxAdapter) Method(java.lang.reflect.Method) KeyCode(javafx.scene.input.KeyCode) Rectangle2D(javafx.geometry.Rectangle2D) Node(javafx.scene.Node) Motion(org.testfx.robot.Motion) VirtualFlow(com.sun.javafx.scene.control.skin.VirtualFlow) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) Screen(javafx.stage.Screen) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) Stage(javafx.stage.Stage) RobotKeywordOverload(org.robotframework.javalib.annotation.RobotKeywordOverload) TableViewSkin(com.sun.javafx.scene.control.skin.TableViewSkin) Window(javafx.stage.Window) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Node(javafx.scene.Node) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 18 with RobotKeyword

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);
    }
}
Also used : JavaFXLibraryFatalException(javafxlibrary.exceptions.JavaFXLibraryFatalException) File(java.io.File) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 19 with RobotKeyword

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryFatalException(javafxlibrary.exceptions.JavaFXLibraryFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword)

Example 20 with RobotKeyword

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);
    }
}
Also used : JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) URL(java.net.URL) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) JavaFXLibraryFatalException(javafxlibrary.exceptions.JavaFXLibraryFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword)

Aggregations

RobotKeyword (org.robotframework.javalib.annotation.RobotKeyword)34 JavaFXLibraryNonFatalException (javafxlibrary.exceptions.JavaFXLibraryNonFatalException)33 ArgumentNames (org.robotframework.javalib.annotation.ArgumentNames)30 Node (javafx.scene.Node)10 JavaFXLibraryFatalException (javafxlibrary.exceptions.JavaFXLibraryFatalException)5 Method (java.lang.reflect.Method)4 Window (javafx.stage.Window)4 PseudoClass (javafx.css.PseudoClass)3 BoundingBox (javafx.geometry.BoundingBox)3 Scene (javafx.scene.Scene)3 Image (javafx.scene.image.Image)3 TableViewSkin (com.sun.javafx.scene.control.skin.TableViewSkin)2 VirtualFlow (com.sun.javafx.scene.control.skin.VirtualFlow)2 ObservableList (javafx.collections.ObservableList)2 Bounds (javafx.geometry.Bounds)2 Rectangle2D (javafx.geometry.Rectangle2D)2 InstanceOfMatcher (javafxlibrary.matchers.InstanceOfMatcher)2 ListViewSkin (com.sun.javafx.scene.control.skin.ListViewSkin)1 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1