diff --git a/.gitattributes b/.gitattributes
index 35efda5..08b6e8e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,3 @@
-# https://git-scm.com/docs/gitattributes
-# unix line feeds to every file (if dos linefeeds needed can be overridden)
+# https://git-scm.com/docs/gitattributes
+# unix line feeds to every file (if dos linefeeds needed can be overridden)
* -text
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 7243480..889580c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ JavaFXLib-*.png
.idea
*.iml
report-images
+*.DS_Store
# temporary pom file by shade plugin
dependency-reduced-pom.xml
diff --git a/pom.xml b/pom.xml
index 91d351c..ec9144e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,31 +105,31 @@
- org.codehaus.mojo
- build-helper-maven-plugin
- 3.2.0
-
-
- attach-artifacts
- package
-
- attach-artifact
-
-
-
-
- ${project.build.directory}/${project.artifactId}.html
- html
-
-
- ${project.build.directory}/${project.artifactId}.xml
- xml
-
-
-
-
-
-
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.2.0
+
+
+ attach-artifacts
+ package
+
+ attach-artifact
+
+
+
+
+ ${project.build.directory}/${project.artifactId}.html
+ html
+
+
+ ${project.build.directory}/${project.artifactId}.xml
+ xml
+
+
+
+
+
+
org.apache.maven.plugins
maven-gpg-plugin
@@ -164,207 +164,207 @@
-
-
-
- src/main/resources
- true
-
- **/*.properties
-
-
-
- src/main/resources
- false
-
- **/*.properties
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.2
-
-
- -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
-
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.8
- true
-
- ossrh
- https://oss.sonatype.org/
- false
-
-
-
- maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.2.0
-
-
-
- true
- JavaFXLibrary
-
-
- JavaFXLibrary
-
-
-
-
-
-
- test-jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 3.3.0
-
-
- package
-
- single
-
-
-
-
-
-
- JavaFXLibrary
-
-
-
- jar-with-dependencies
-
-
-
-
- org.robotframework
- robotframework-maven-plugin
- 1.7.1
-
-
- acceptance tests
- integration-test
-
- run
-
-
-
- smoke
-
-
- not-ready
-
-
- monocle-issue
-
- TRACE:INFO
- false
-
- appJar:${project.build.directory}/${project.artifactId}*tests.jar
-
-
-
-
- documentation
- package
-
- libdoc
-
-
-
- ${project.build.directory}
- ${project.artifactId}.html
- JavaFXLibrary
- ${project.version}
-
-
-
-
- xml
- package
-
- libdoc
-
-
-
- ${project.build.directory}
- ${project.artifactId}.xml
- JavaFXLibrary
- ${project.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.4
-
-
- package
-
- shade
-
-
-
-
- JavaFXLibrary
-
-
-
-
- com.google.common
- shaded.com.google.common
-
-
- org.apache.commons
- shaded.org.apache.commons
-
-
-
-
- *:*
-
-
-
-
- *:*
-
- META-INF/*.SF
- META-INF/*.DSA
- META-INF/*.RSA
-
-
-
-
-
-
-
-
-
+
+
+
+ src/main/resources
+ true
+
+ **/*.properties
+
+
+
+ src/main/resources
+ false
+
+ **/*.properties
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
+ -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.8
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ false
+
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ true
+ JavaFXLibrary
+
+
+ JavaFXLibrary
+
+
+
+
+
+
+ test-jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.3.0
+
+
+ package
+
+ single
+
+
+
+
+
+
+ JavaFXLibrary
+
+
+
+ jar-with-dependencies
+
+
+
+
+ org.robotframework
+ robotframework-maven-plugin
+ 1.7.1
+
+
+ acceptance tests
+ integration-test
+
+ run
+
+
+
+ smoke
+
+
+ not-ready
+
+
+ monocle-issue
+
+ TRACE:INFO
+ false
+
+ appJar:${project.build.directory}/${project.artifactId}*tests.jar
+
+
+
+
+ documentation
+ package
+
+ libdoc
+
+
+
+ ${project.build.directory}
+ ${project.artifactId}.html
+ JavaFXLibrary
+ ${project.version}
+
+
+
+
+ xml
+ package
+
+ libdoc
+
+
+
+ ${project.build.directory}
+ ${project.artifactId}.xml
+ JavaFXLibrary
+ ${project.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.4
+
+
+ package
+
+ shade
+
+
+
+
+ JavaFXLibrary
+
+
+
+
+ com.google.common
+ shaded.com.google.common
+
+
+ org.apache.commons
+ shaded.org.apache.commons
+
+
+
+
+ *:*
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+
+
+
+
@@ -409,15 +409,10 @@
1.3
- com.google.guava
- guava
- 29.0-jre
+ org.robotframework
+ jrobotremoteserver
+ 4.0.1
-
- org.robotframework
- jrobotremoteserver
- 4.0.0
-
org.apache.commons
commons-lang3
diff --git a/src/.gitignore b/src/.gitignore
deleted file mode 100644
index 7dd6e6b..0000000
--- a/src/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-target
-.idea
-*.iml
\ No newline at end of file
diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java
index a7c4b4d..2b54eb9 100644
--- a/src/main/java/JavaFXLibrary.java
+++ b/src/main/java/JavaFXLibrary.java
@@ -15,16 +15,6 @@
* limitations under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicReference;
-
import javafxlibrary.exceptions.JavaFXLibraryFatalException;
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
import javafxlibrary.exceptions.JavaFXLibraryTimeoutException;
@@ -41,10 +31,18 @@
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
-import static org.testfx.util.WaitForAsyncUtils.*;
-import static javafxlibrary.utils.HelperFunctions.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
-import java.util.ResourceBundle;
+import static javafxlibrary.utils.HelperFunctions.getLibraryKeywordTimeout;
+import static org.testfx.util.WaitForAsyncUtils.*;
public class JavaFXLibrary extends AnnotationLibrary {
@@ -201,7 +199,7 @@ public Object runKeyword(String keywordName, List args, Map kwargs) {
return null;
}
}));
- waitForFxEvents( 5);
+ waitForFxEvents(5);
}
} catch (JavaFXLibraryTimeoutException jfxte) {
// timeout already expired, catch exception and jump out
@@ -212,7 +210,7 @@ public Object runKeyword(String keywordName, List args, Map kwargs) {
}
// in failure take screenshot and handle exception
- if(retExcep.get()!=null) {
+ if (retExcep.get() != null) {
RobotLog.reset();
RuntimeException e = retExcep.get();
runOnFailure.runOnFailure();
diff --git a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryFatalException.java b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryFatalException.java
index 9fdde6e..ad21f84 100644
--- a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryFatalException.java
+++ b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryFatalException.java
@@ -18,7 +18,7 @@
package javafxlibrary.exceptions;
@SuppressWarnings("serial")
-public class JavaFXLibraryFatalException extends JavaFXLibraryKeywordException {
+public class JavaFXLibraryFatalException extends JavaFXLibraryKeywordException {
/**
* Avoid adding the exception type as a prefix to failure messages
diff --git a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryKeywordException.java b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryKeywordException.java
index 57e4582..9828cef 100644
--- a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryKeywordException.java
+++ b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryKeywordException.java
@@ -22,7 +22,6 @@ public class JavaFXLibraryKeywordException extends RuntimeException {
/**
* Avoid adding the exception type as a prefix to failure messages
- *
*/
public static final boolean ROBOT_SUPPRESS_NAME = true;
diff --git a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryNonFatalException.java b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryNonFatalException.java
index b0d41cc..8aca426 100644
--- a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryNonFatalException.java
+++ b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryNonFatalException.java
@@ -18,7 +18,7 @@
package javafxlibrary.exceptions;
@SuppressWarnings("serial")
-public class JavaFXLibraryNonFatalException extends JavaFXLibraryKeywordException {
+public class JavaFXLibraryNonFatalException extends JavaFXLibraryKeywordException {
/**
* This will be a non-fatal exception
diff --git a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryTimeoutException.java b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryTimeoutException.java
index 8b02fa1..92e0f33 100644
--- a/src/main/java/javafxlibrary/exceptions/JavaFXLibraryTimeoutException.java
+++ b/src/main/java/javafxlibrary/exceptions/JavaFXLibraryTimeoutException.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2017-2018 Eficode Oy
- * Copyright 2018- Robot Framework Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package javafxlibrary.exceptions;
-
-@SuppressWarnings("serial")
-public class JavaFXLibraryTimeoutException extends JavaFXLibraryNonFatalException {
-
- public JavaFXLibraryTimeoutException() {
- super();
- }
-
- public JavaFXLibraryTimeoutException(String string) {
- super(string);
- }
-
- public JavaFXLibraryTimeoutException(Throwable t) {
- super(t);
- }
-
- public JavaFXLibraryTimeoutException(String string, Throwable t) {
- super(string, t);
- }
-}
+/*
+ * Copyright 2017-2018 Eficode Oy
+ * Copyright 2018- Robot Framework Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javafxlibrary.exceptions;
+
+@SuppressWarnings("serial")
+public class JavaFXLibraryTimeoutException extends JavaFXLibraryNonFatalException {
+
+ public JavaFXLibraryTimeoutException() {
+ super();
+ }
+
+ public JavaFXLibraryTimeoutException(String string) {
+ super(string);
+ }
+
+ public JavaFXLibraryTimeoutException(Throwable t) {
+ super(t);
+ }
+
+ public JavaFXLibraryTimeoutException(String string, Throwable t) {
+ super(string, t);
+ }
+}
diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java
index e5e7ab1..57cc01f 100644
--- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java
+++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java
@@ -48,7 +48,7 @@ public class ApplicationLauncher extends TestFxAdapter {
+ "Example:\n"
+ "| Launch JavaFX Application | _javafxlibrary.testapps.MenuApp_ |\n"
+ "| Launch JavaFX Application | _TestApplication.jar_ |\n")
- @ArgumentNames({ "appName", "*args" })
+ @ArgumentNames({"appName", "*args"})
public void launchJavafxApplication(String appName, String... appArgs) {
try {
RobotLog.info("Starting application:" + appName);
@@ -69,7 +69,7 @@ public void launchJavafxApplication(String appName, String... appArgs) {
+ "Example:\n"
+ "| Launch Swing Application | _javafxlibrary.testapps.SwingApplication_ |\n"
+ "| Launch Swing Application | _TestApplication.jar_ |\n")
- @ArgumentNames({ "appName", "*args" })
+ @ArgumentNames({"appName", "*args"})
public void launchSwingApplication(String appName, String... appArgs) {
RobotLog.info("Starting application:" + appName);
Class mainClass = getMainClass(appName);
@@ -89,7 +89,7 @@ public void launchSwingApplication(String appName, String... appArgs) {
+ "Example:\n"
+ "| Launch Swing Application In Separate Thread | _javafxlibrary.testapps.SwingApplication_ |\n"
+ "| Launch Swing Application In Separate Thread | _TestApplication.jar_ |\n")
- @ArgumentNames({ "appName", "*args" })
+ @ArgumentNames({"appName", "*args"})
public void launchSwingApplicationInSeparateThread(String appName, String... appArgs) {
RobotLog.info("Starting application:" + appName);
Class c = getMainClass(appName);
@@ -134,7 +134,7 @@ private void addPathToClassPath(String path) {
+ "| Set To Classpath | C:${/}users${/}my${/}test${/}folder | \n"
+ "| Set To Classpath | C:${/}users${/}my${/}test${/}folder${/}* | \n"
+ "| Set To Classpath | C:${/}users${/}my${/}test${/}folder2${/}* | failIfNotFound=${True} | \n")
- @ArgumentNames({ "path", "failIfNotFound=False" })
+ @ArgumentNames({"path", "failIfNotFound=False"})
public void setToClasspath(String path, boolean failIfNotFound) {
RobotLog.info("Setting \"" + path + "\" to classpath, failIfNotFound=\"" + failIfNotFound + "\"");
if (path.endsWith("*")) {
@@ -190,7 +190,7 @@ public void logApplicationClasspath() {
@RobotKeyword("Sets system property ``name`` to ``value``. Equals command line usage `-Dname=value`.\n"
+ "\nExample:\n"
+ "| Set System Property | locale | en_US | \n")
- @ArgumentNames({ "name", "value" })
+ @ArgumentNames({"name", "value"})
public void setSystemProperty(String name, String value) {
try {
System.setProperty(name, value);
@@ -203,7 +203,7 @@ public void setSystemProperty(String name, String value) {
+ "``name`` is the system property name to fetch. \n"
+ "\nExample:\n"
+ "| ${locale}= | Get System Property | locale | \n")
- @ArgumentNames({ "name" })
+ @ArgumentNames({"name"})
public String getSystemProperty(String name) {
try {
return System.getProperty(name);
@@ -272,7 +272,7 @@ public String getCurrentApplication() {
@RobotKeyword("Waits for current events in Fx Application Thread event queue to finish before continuing.\n\n"
+ "``timeout`` is the maximum time in seconds that the events will be waited for. If the timeout is "
+ "exceeded the keyword will fail. Default timeout is 5 seconds.\n\n")
- @ArgumentNames({ "timeout=5" })
+ @ArgumentNames({"timeout=5"})
public void waitForEventsInFxApplicationThread(int timeout) {
final Throwable[] threadException = new JavaFXLibraryNonFatalException[1];
diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java
index 9b3e666..531cc7d 100644
--- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java
+++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java
@@ -1,892 +1,892 @@
-/*
- * Copyright 2017-2018 Eficode Oy
- * Copyright 2018- Robot Framework Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package javafxlibrary.keywords.AdditionalKeywords;
-
-import com.sun.javafx.scene.control.skin.TableViewSkin;
-import com.sun.javafx.scene.control.skin.VirtualFlow;
-import javafx.collections.ObservableList;
-import javafx.css.PseudoClass;
-import javafx.geometry.BoundingBox;
-import javafx.geometry.Rectangle2D;
-import javafx.scene.Node;
-import javafx.scene.Parent;
-import javafx.scene.control.*;
-import javafx.scene.image.Image;
-import javafx.scene.input.KeyCode;
-import javafx.stage.Screen;
-import javafx.stage.Stage;
-import javafx.stage.Window;
-import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
-import javafxlibrary.keywords.Keywords.ClickRobot;
-import javafxlibrary.keywords.Keywords.KeyboardRobot;
-import static javafxlibrary.utils.HelperFunctions.*;
-import javafxlibrary.utils.HelperFunctions;
-import javafxlibrary.utils.RobotLog;
-import javafxlibrary.utils.TestFxAdapter;
-import javafxlibrary.utils.finder.XPathFinder;
-import org.robotframework.javalib.annotation.ArgumentNames;
-import org.robotframework.javalib.annotation.RobotKeyword;
-import org.robotframework.javalib.annotation.RobotKeywords;
-import org.testfx.robot.Motion;
-
-import java.lang.reflect.Method;
-import java.util.*;
-
-import static org.testfx.util.WaitForAsyncUtils.waitForFxEvents;
-
-@RobotKeywords
-public class ConvenienceKeywords extends TestFxAdapter {
-
- @RobotKeyword("Brings the given stage to front\n\n"
- + "``stage`` is an Object:Stage to be set in front of others, see `3.2 Using locators as keyword arguments`. \n\n")
- @ArgumentNames({ "stage" })
- public void bringStageToFront(Stage stage) {
- RobotLog.info("Bringing following Stage to front: \"" + stage + "\"");
- try {
- robot.targetWindow(stage);
- stage.toFront();
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Unable to bring stage to front.", e);
- }
- }
-
- @RobotKeyword("Calls a given method for a given java object.\n\n"
- + "``object`` is a Java object retrieved using JavaFXLibrary keywords, see `3.2 Using locators as keyword arguments`.\n\n"
- + "``method`` is the name of the method that will be called.\n\n"
- + "Optional ``arguments`` are variable-length arguments that will be provided for the method.\n "
- + "If argument type is boolean, byte, char, double, float, int, long or short, it must have \"casting instructions\" "
- + "in front of it, e.g. _\"(boolean)false\"_.\n\n"
- + "\nExample:\n"
- + "| ${node}= | Find | id=node-id | \n"
- + "| ${max height}= | Call Object Method | ${node} | maxHeight | (double)10 | \n"
- + "| ${node text}= | Call Object Method | ${node} | getText | \n")
- @ArgumentNames({ "object", "method", "*arguments=" })
- public Object callObjectMethod(Object object, String method, Object... arguments) {
- /* Javalib Core changes all parameters to Strings after runKeywords automatic argument replacement, so arguments
- are replaced with objects from objectMap here instead. */
- object = useMappedObject(object);
- Object[] tempArgs = checkMethodArguments(arguments);
- Object[] finalArgs = useMappedObjects(tempArgs);
- Object result = callMethod(object, method, finalArgs, false);
- if (result != null)
- return mapObject(result);
- return null;
- }
-
- @RobotKeyword("Calls given method in FX Application Thread using Platform.runLater(). See `Call Object Method` "
- + "for further documentation.\n\n"
- + "\nExample:\n"
- + "| ${node}= | Find | id=node-id | \n"
- + "| Call Object Method In Fx Application Thread | ${node} | maxHeight | (boolean)false | \n")
- @ArgumentNames({ "object", "method", "*arguments=" })
- public void callObjectMethodInFxApplicationThread(Object object, String method, Object... arguments) {
- // Check callObjectMethod for info about argument replacing.
- object = useMappedObject(object);
- Object[] tempArgs = checkMethodArguments(arguments);
- Object[] finalArgs = useMappedObjects(tempArgs);
- callMethod(object, method, finalArgs, true);
- waitForFxEvents(3);
- }
-
- @RobotKeyword("Lists methods available for given node.\n"
- + "``node`` is the Object:Node which methods to list, see `3.2 Using locators as keyword arguments`. \n\n"
- + "When working with custom components you may use this keyword to discover methods you can call "
- + "with `Call Object Method` or `Call Object Method In Fx Application Thread` keyword.\n\n"
- + "Example:\n"
- + "| List Node Methods | ${my node} |\n")
- @ArgumentNames({ "node" })
- public String[] listNodeMethods(Node node) {
- try {
- RobotLog.info("Listing all available methods for node: \"" + node + "\"");
- Class nodeClass = node.getClass();
- ArrayList list = new ArrayList<>();
- System.out.println("*INFO*");
- while (nodeClass != null) {
- String name = String.format("\n*%s*\n", nodeClass.getName());
- System.out.println(name);
- list.add(name);
- for (Method m : nodeClass.getDeclaredMethods()) {
- String entry = getMethodDescription(m);
- System.out.println(entry);
- list.add(entry);
- }
- nodeClass = nodeClass.getSuperclass();
- }
- return list.toArray(new String[0]);
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Listing node methods failed.", e);
- }
- }
-
- private String getMethodDescription(Method m) {
- StringBuilder entry = new StringBuilder(m.getReturnType().getName() + " ");
- entry.append(m.getName());
- entry.append("(");
- Class[] args = m.getParameterTypes();
- for (int i = 0; i < args.length; i++) {
- entry.append(args[i].getName());
- if (i != args.length - 1)
- entry.append(", ");
- }
- return entry + ")";
- }
-
- @RobotKeyword("Prints all child nodes starting from a given node.\n\n"
- + "Optional argument ``root`` is the starting point from where to start listing child nodes, "
- + "see `3.2 Using locators as keyword arguments`. Defaults to root node of current window. \n\n"
- + "\nExample:\n"
- + "| ${my node}= | Find | id=node-id | \n"
- + "| Print Child Nodes | ${my node} | \n")
- @ArgumentNames({ "root=" })
- public void printChildNodes(Object root) {
- try {
- RobotLog.info("Printing tree structure for node: \"" + root + "\"");
- printTreeStructure((Parent) objectToNode(root));
- } catch (ClassCastException e) {
- throw new JavaFXLibraryNonFatalException(root.getClass() + " is not a subclass of javafx.scene.Parent");
- }
- }
-
- // TODO: Should printChildNodes be deprecated?
- @RobotKeyword("Generates and prints FXML representation of the application starting from a given node.\n\n"
- + "Optional argument ``root`` is the starting point from where to start listing child nodes, "
- + "see `3.2 Using locators as keyword arguments`. Defaults to root node of current window. \n\n"
- + "\nExample:\n"
- + "| ${my node}= | Find | id=node-id | \n"
- + "| Log FXML | ${my node} | \n")
- @ArgumentNames({"root="})
- public void logFXML(Object root) {
- RobotLog.info("Logging FXML of root \"" + root + "\".");
- XPathFinder logger = new XPathFinder();
- logger.setNodeLogging(false);
- RobotLog.info(logger.getFxml((Parent) objectToNode(root)));
- }
-
- @RobotKeyword("Enables/Disables clicking outside of visible JavaFX application windows. Safe clicking is on by" +
- " default, preventing clicks outside of the tested application.\n\n" +
- "``value`` can be any of the following: on, off.\n\n"
- + "Parameter _value_ specifies whether safety should be toggled on or off")
- @ArgumentNames({ "value" })
- public void setSafeClicking(String value) {
- switch (value.toLowerCase()) {
- case "off":
- RobotLog.info("Setting safe clicking mode to OFF");
- HelperFunctions.setSafeClicking(false);
- break;
- case "on":
- RobotLog.info("Setting safe clicking mode to ON");
- HelperFunctions.setSafeClicking(true);
- break;
- default:
- throw new JavaFXLibraryNonFatalException("Unknown value: \"" + value + "\". Expected values are `on` or `off`");
- }
- }
-
- @RobotKeyword("Sets the maximum time library waits for keyword to finish. Keyword returns old timeout value as return "
- + "value. Default value is 10 seconds.\n\n"
- + "``timeout`` is an Integer value for timeout in seconds.\n\n"
- + "\nExample:\n"
- + "| ${old_timeout}= | Set Timeout | 20 | \n"
- + "| Click On | id=myidthatshallcomeavailable | | \n"
- + "| [Teardown] | Set Timeout | ${old_timeout} | \n")
- @ArgumentNames({ "timeout" })
- public Integer setTimeout(int timeout) {
- RobotLog.info("Setting timeout to " + timeout + "s");
- Integer oldTimeoutValue = getLibraryKeywordTimeout();
- setLibraryKeywordTimeout(timeout);
- return oldTimeoutValue;
- }
-
- /*
- * 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) {
- try {
- RobotLog.info("Switching window for: \"" + switchAmount + "\" times.");
- 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);
- }
- }
-
- // TODO: Implement getNodeProperty keyword and deprecate below get* keywords
- @RobotKeyword("Calls getPseudoClassStates() -method for a given node and returns a list of values returned by the method.\n\n"
- + "``locator`` is either a _query_ or _Object_ for node whose pseudo class states will be queried, see "
- + "`3. Locating JavaFX Nodes`. \n\n"
- + "\nExample:\n"
- + "| ${states}= | Get Pseudo Class States | ${node} | \n"
- + "| Log List | ${states} | \n")
- @ArgumentNames({ "node" })
- public Set getPseudoClassStates(Object locator) {
- checkObjectArgumentNotNull(locator);
- try {
- RobotLog.info("Getting pseudoclass states for node: \"" + locator + "\"");
- Node node = objectToNode(locator);
- return node.getPseudoClassStates();
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Unable to get pseudoClassStates for locator: " + locator);
- }
- }
-
- @RobotKeyword("Returns text value of the Node. \n\n"
- + "``locator`` is either a _query_ or _Object_ for a node whose getText method will be called, see "
- + "`3. Locating JavaFX Nodes`. \n\n")
- @ArgumentNames({ "locator" })
- public String getNodeText(Object locator) {
- checkObjectArgumentNotNull(locator);
- Node node = objectToNode(locator);
- try {
- RobotLog.info("Getting text value for node: \"" + node + "\"");
- Class extends Node> c = node.getClass();
- return (String) c.getMethod("getText").invoke(node);
- } catch (NoSuchMethodException e) {
- throw new JavaFXLibraryNonFatalException("Get node text failed for node: " + node + ": Node has no getText method");
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Get node text failed for node: " + node, e);
- }
- }
-
- @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 JavaFX Nodes`. \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) {
- checkObjectArgumentNotNull(locator);
- Node node = objectToNode(locator);
- try {
- RobotLog.info("Getting image url from node: \"" + node + "\"");
- 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 + "\"");
- try {
- Object result = m.invoke(node, (Object) null);
- Image image = (Image) result;
- RobotLog.trace("Calling deprecated method impl_getUrl() for image: \"" + image + "\"");
- 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 );
- }
- }
-
- @RobotKeyword("Returns the parent node of node. \n\n"
- + "``locator`` is either a _query_ or _Object_ for a node whose getParent method will be called, see "
- + "`3. Locating JavaFX Nodes`. \n\n")
- @ArgumentNames({ "locator" })
- public Object getNodeParent(Object locator) {
- checkObjectArgumentNotNull(locator);
- Node node = objectToNode(locator);
- try {
- RobotLog.info("Getting node parent object for: \"" + node + "\"");
- return mapObject(node.getParent());
- } catch (Exception e) {
- if( e instanceof JavaFXLibraryNonFatalException )
- throw e;
- throw new JavaFXLibraryNonFatalException("Unable to get node parent for node: " + node.toString(), e);
- }
- }
-
- @RobotKeyword("Returns the class name of a given node. \n\n"
- + "``locator`` is either a _query_ or _Object_ for a node whose getSimpleName method will be called, see "
- + "`3. Locating JavaFX Nodes`. \n\n")
- @ArgumentNames({ "locator" })
- public String getObjectClassName(Object locator) {
- checkObjectArgumentNotNull(locator);
- Node node = objectToNode(locator);
- try {
- RobotLog.info("Getting class name for object: \"" + node + "\"");
- return node.getClass().getSimpleName();
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Unable to get class name for object: " + node.toString(), e);
- }
- }
-
- @RobotKeyword("Returns Scene of the given object. \n\n"
- + "``locator`` is either a _query_, a _Node_ or a _Window_, see `3.2 Using locators as keyword arguments`\n\n")
- @ArgumentNames({ "locator" })
- public Object getScene(Object locator) {
- checkObjectArgumentNotNull(locator);
- try {
- RobotLog.info("Getting a Scene object for: \"" + locator + "\"");
- if (locator instanceof Node){
- return mapObject(((Node) locator).getScene());
- } else if (locator instanceof String) {
- Node node = objectToNode(locator);
- return mapObject(node.getScene());
- } else if (locator instanceof Window) {
- return mapObject(((Window) locator).getScene());
- }
- throw new JavaFXLibraryNonFatalException("Unsupported locator type. Locator must be an instance of Node, String or Window!");
- } catch (Exception e) {
- if (e instanceof JavaFXLibraryNonFatalException)
- throw e;
- throw new JavaFXLibraryNonFatalException("Unable to get Scene object for locator: \"" + locator + "\"", e);
- }
- }
-
- @RobotKeyword("Returns the title of the given window. \n\n"
- + "``locator`` is an _Object:Window_ whose getTitle method will be called, see "
- + "`3.2 Using locators as keyword arguments`. This keyword can be coupled with e.g. `List Windows` -keyword.\n\n")
- @ArgumentNames({ "window" })
- public String getWindowTitle(Object object) {
- checkObjectArgumentNotNull(object);
- try {
- RobotLog.info("Getting the window title for: \"" + object + "\"");
- Method m = object.getClass().getMethod("getTitle");
- return (String) m.invoke(object, (Object[]) null);
- } catch (NoSuchMethodException e) {
- RobotLog.info("This window type has no getTitle() -method. Returning null");
- return "";
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Unable to get title for window: " + object.toString(), e);
- }
- }
-
- @RobotKeyword("Returns the bounds of primary screen. \n")
- public Object getPrimaryScreenBounds() {
- try {
- RobotLog.info("Getting the primary screen bounds");
- Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
- return mapObject(new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
- } catch (Exception e) {
- throw new JavaFXLibraryNonFatalException("Unable to get primary screen bounds.", e);
- }
- }
-
- @RobotKeyword("Returns the JavaFXLibrary version.")
- public String getLibraryVersion() {
- return getVersion();
- }
-
- @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 JavaFX Nodes`. \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) {
- checkObjectArgumentNotNull(locator);
- try {
- RobotLog.info("Getting table \"" + locator + "\" cell value from row \"" + row + "\" and column \"" + column + "\".");
- 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 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");
- }
- }
-
- @RobotKeyword("Returns the Node of cell in the given table location\n\n"
- + "``locator`` is either a _query_ or _Object:Node_ for identifying the TableView element, see "
- + "`3. Locating JavaFX Nodes`. \n\n"
- + "``row`` Integer value for the row\n\n"
- + "``column`` Integer value for the column")
- @ArgumentNames({ "table", "row", "column" })
- public Object getTableCell(Object locator, int row, int column) {
- checkObjectArgumentNotNull(locator);
- try {
- RobotLog.info("Getting table \"" + locator + "\" cell from row \"" + row + "\" and column \"" + column + "\".");
- TableView table = (TableView) objectToNode(locator);
- return mapObject(getTableRowCell(table, row, column));
- } catch (ClassCastException cce) {
- throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
- }
- }
-
- @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 JavaFX Nodes`. \n\n"
- + "``column`` Integer value for the column")
- @ArgumentNames({ "table", "column" })
- public List