From cb2e8c6ce3be1c8982046ba47d8ca25eee8596d3 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Wed, 22 Jan 2020 16:21:34 +0200 Subject: [PATCH 01/20] 0.5.5-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c236ecc..cacd1bf 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.4 + 0.5.5-SNAPSHOT UTF-8 1.44 From 569bf020215ce64bf5c17667bce70c214a5f850e Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 27 Jan 2020 10:35:34 +0200 Subject: [PATCH 02/20] add info log to find all kw --- .../java/javafxlibrary/keywords/AdditionalKeywords/Find.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Find.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Find.java index 4d7af24..1ad4417 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Find.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Find.java @@ -72,6 +72,8 @@ public Object find(String query, boolean failIfNotFound, Parent root) { @ArgumentNames({"query", "failIfNotFound=False", "root="}) public List findAll(String query, boolean failIfNotFound, Parent root) { try { + RobotLog.info("Trying to find all nodes matching the query: \"" + query + "\", failIfNotFound=\"" + + failIfNotFound + "\", root=\"" + root + "\""); if (root != null) { return mapObjects(new Finder().findAll(query, root)); } else { From e8c4e052de69f5d70cdc0db3b09f4232de19257a Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 15:58:25 +0300 Subject: [PATCH 03/20] Fix classpath handling, closes #38 --- .../AdditionalKeywords/ApplicationLauncher.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java index 1540b7a..6c6a117 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java @@ -29,6 +29,7 @@ import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.FileSystems; import java.util.*; import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication; @@ -106,7 +107,7 @@ private Class getMainClass(String appName) { private void _addPathToClassPath(String path) { URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - RobotLog.info("Setting following path to Classpath: " + path); + RobotLog.info("Setting following path to classpath: " + path); try { Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); @@ -133,11 +134,14 @@ public void setToClasspath(String path) { try { File directory = new File(path); File[] fileList = directory.listFiles(); - - for (File file : fileList) { - if (file.getName().endsWith(".jar")) + boolean jarsFound = false; + for (File file : Objects.requireNonNull(fileList)) { + if (file.getName().endsWith(".jar")) { + jarsFound = true; _addPathToClassPath(file.getAbsolutePath()); + } } + if(!jarsFound) throw new JavaFXLibraryNonFatalException("No jar files found from classpath: " + FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString()); } catch (NullPointerException e) { throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e); } @@ -160,7 +164,7 @@ public void logApplicationClasspath() { } } - @RobotKeyword("Sets system property ``name`` to ``value``. Equals commmand line usage `-Dname=value`.\n" + @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" }) From 95c424a333a7138cb735b03b99098f8c68e680ed Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 16:01:09 +0300 Subject: [PATCH 04/20] Fix screen capturing temp file usage, fixes #36 --- .../keywords/Keywords/ScreenCapturing.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index cd2a2b0..1d4532f 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -25,6 +25,7 @@ import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords; import javafxlibrary.utils.RobotLog; import javafxlibrary.utils.TestFxAdapter; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.robotframework.javalib.annotation.ArgumentNames; import org.robotframework.javalib.annotation.RobotKeyword; @@ -97,7 +98,7 @@ public Object captureImage(Object locator, boolean logImage){ robotContext().getCaptureSupport().saveImage(image, path); if (logImage) { - Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); + double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); if(TestFxAdapter.logImages.toLowerCase().equals("embedded")) { Image resizedImage = resizeImage(image, path); @@ -105,10 +106,13 @@ public Object captureImage(Object locator, boolean logImage){ robotContext().getCaptureSupport().saveImage(resizedImage, tempPath); File imageFile = convertToJpeg(tempPath); - byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); + byte[] imageBytes = FileUtils.readFileToByteArray(imageFile); String encodedImage = Base64.getEncoder().encodeToString(imageBytes); - imageFile.delete(); - + if(imageFile.exists()) { + if (!imageFile.delete()) { + RobotLog.warn("Capture temporary image \"" + imageFile.getAbsolutePath() + "\" deletion failed."); + } + } RobotLog.html("" + "" + ""); @@ -131,7 +135,7 @@ public Object captureImage(Object locator, boolean logImage){ } } - @RobotKeyword("Returns a screenshot of the scene conatining given locator.\n\n" + @RobotKeyword("Returns a screenshot of the scene containing given locator.\n\n" + "``locator`` is a query locator, see `3.1 Locator syntax`.\n\n " + "\nExample:\n" + "| ${capture}= | Capture Scene Containing Node | ${node} | \n" ) @@ -189,17 +193,19 @@ public void saveImageAs(Image image, String path) { private Path createNewImageFileNameWithPath(){ ZonedDateTime errorDateTime = ZonedDateTime.now(); - String errorTimestamp = formatErrorTimestamp(errorDateTime, "yyyyMMdd-HHmmss-SSS"); + String errorTimestamp = formatErrorTimestamp(errorDateTime); String errorImageFilename = "JavaFXLib-" + errorTimestamp + ".png"; String errorImageFilePath = getCurrentSessionScreenshotDirectory(); File errDir = new File(errorImageFilePath); if(!errDir.exists()) - errDir.mkdirs(); + if (!errDir.mkdirs()) { + RobotLog.warn("Capture image directory \"" + errorImageFilePath + "\" creation failed."); + } return Paths.get(errorImageFilePath, errorImageFilename); } - private static String formatErrorTimestamp(ZonedDateTime dateTime, String dateTimePattern) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimePattern); + private static String formatErrorTimestamp(ZonedDateTime dateTime) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss-SSS"); return dateTime.format(formatter); } @@ -225,7 +231,11 @@ private File convertToJpeg(Path path) throws IOException { BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB); newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, java.awt.Color.WHITE, null); - path.toFile().delete(); + if(path.toFile().exists()) { + if (!path.toFile().delete()) { + RobotLog.warn("Capture temporary image \"" + path + "\" deletion failed."); + } + } Path tempPathJpeg = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.jpg"); ImageIO.write(newBufferedImage, "jpg", tempPathJpeg.toFile()); return tempPathJpeg.toFile(); From 793e3a76abef98010dd46ee41e42b3b88f8b2fa7 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 16:05:49 +0300 Subject: [PATCH 05/20] Fix Node Should Be Hoverable Keyword to preperly move pointer, fixes #37 --- .../matchers/ExtendedNodeMatchers.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/javafxlibrary/matchers/ExtendedNodeMatchers.java b/src/main/java/javafxlibrary/matchers/ExtendedNodeMatchers.java index 0b6aeb0..89ae237 100644 --- a/src/main/java/javafxlibrary/matchers/ExtendedNodeMatchers.java +++ b/src/main/java/javafxlibrary/matchers/ExtendedNodeMatchers.java @@ -19,12 +19,20 @@ import javafx.geometry.Bounds; import javafx.scene.Node; +import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; +import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; import javafxlibrary.utils.HelperFunctions; +import javafxlibrary.utils.RobotLog; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; +import java.util.concurrent.TimeoutException; + import static javafxlibrary.utils.HelperFunctions.getHoveredNode; +import static org.testfx.util.WaitForAsyncUtils.waitFor; +import static org.testfx.util.WaitForAsyncUtils.asyncFx; +import static org.testfx.util.WaitForAsyncUtils.waitForFxEvents; public class ExtendedNodeMatchers { @@ -48,8 +56,21 @@ public void describeMismatch(Object object, Description description) { } private static boolean hoverable(Node node) { - new javafxlibrary.keywords.Keywords.MoveRobot().moveTo(node,"DIRECT"); - return node.isHover(); + try { + waitFor(HelperFunctions.getWaitUntilTimeout(), HelperFunctions.getTimeUnit("SECONDS"), () -> { + return asyncFx(() -> new javafxlibrary.keywords.Keywords.MoveRobot().moveTo(node, "DIRECT") != null).get(); + }); + waitForFxEvents(); + return node.isHover(); + } catch (JavaFXLibraryNonFatalException nfe) { + throw nfe; + } catch (TimeoutException te) { + throw new JavaFXLibraryTimeoutException("Given element \"" + node + "\" was not found within given timeout of " + + HelperFunctions.getWaitUntilTimeout() + " " + "SECONDS"); + } catch (Exception e) { + RobotLog.trace("Exception in hoverable matcher: " + e + "\n" + e.getCause().toString()); + throw new JavaFXLibraryNonFatalException("hoverable matcher failed: ", e); + } } public static boolean hasValidCoordinates(Node node) { From b401126ececba2d32a80d59bc6b1a0bcd412cca1 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 16:08:09 +0300 Subject: [PATCH 06/20] Fix Move To keyword to handle not foundable queries properly, added related test, fixes #39 --- .../javafxlibrary/keywords/Keywords/MoveRobot.java | 14 ++++++++++---- .../robotframework/acceptance/MoveRobotTest.robot | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/Keywords/MoveRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/MoveRobot.java index 9f2328f..3da2df5 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/MoveRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/MoveRobot.java @@ -49,9 +49,15 @@ public class MoveRobot extends TestFxAdapter { @ArgumentNames({ "locator", "motion=DIRECT" }) public FxRobotInterface moveTo(Object locator, String motion) { RobotLog.info("Moving to target \"" + locator + "\" using motion: \"" + getMotion(motion) + "\""); - - if (locator instanceof String) + if (locator instanceof String) { + String originalLocator = (String) locator; locator = new Finder().find((String) locator); + if(locator==null) { + throw new JavaFXLibraryNonFatalException("Unable to move as locator \"" + originalLocator + "\" not found!"); + } else { + RobotLog.info("Locator at this point: " + locator); + } + } Method method = MethodUtils.getMatchingAccessibleMethod(robot.getClass(), "moveTo", locator.getClass(), Motion.class); @@ -73,7 +79,7 @@ public FxRobotInterface moveTo(Object locator, String motion) { public FxRobotInterface moveBy(int x, int y, String motion) { try { RobotLog.info("Moving by [" + x + ", " + y + "] using motion: \"" + motion + "\""); - return robot.moveBy((double) x, (double) y, HelperFunctions.getMotion(motion)); + return robot.moveBy(x, y, HelperFunctions.getMotion(motion)); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) throw e; @@ -94,7 +100,7 @@ public FxRobotInterface moveBy(int x, int y, String motion) { public FxRobotInterface moveToCoordinates(int x, int y, String motion) { try { RobotLog.info("Moving to coordinates: [" + x + ", " + y + "] using motion: \"" + motion + "\""); - return robot.moveTo((double) x, (double) y, HelperFunctions.getMotion(motion)); + return robot.moveTo(x, y, HelperFunctions.getMotion(motion)); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) throw e; diff --git a/src/test/robotframework/acceptance/MoveRobotTest.robot b/src/test/robotframework/acceptance/MoveRobotTest.robot index 6852c8b..e36aa02 100644 --- a/src/test/robotframework/acceptance/MoveRobotTest.robot +++ b/src/test/robotframework/acceptance/MoveRobotTest.robot @@ -85,6 +85,10 @@ Move To Window ${Y} Convert To Integer ${Y} Verify String id=locationLabel ${X} | ${Y} +Move To Nonexistent Location + [Tags] smoke + Run Keyword And Expect Error Unable to move as locator "css=\#rectangleNOTfound" not found! Move To css=\#rectangleNOTfound + *** Keywords *** Setup all tests Import JavaFXLibrary From dde59e74b4d50efbddedd1eb8e32ee9f2cdbd16f Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 16:15:34 +0300 Subject: [PATCH 07/20] updated dependencies, refactored code --- pom.xml | 26 ++++++------ src/main/java/JavaFXLibrary.java | 4 +- src/main/java/JavaFXLibraryRemoteServer.java | 4 +- .../ConvenienceKeywords.java | 37 +++++++++-------- .../AdditionalKeywords/RunOnFailure.java | 5 +-- .../AdditionalKeywords/Verifiers.java | 11 ++--- .../keywords/Keywords/BoundsLocation.java | 2 +- .../keywords/Keywords/ClickRobot.java | 6 +-- .../keywords/Keywords/DragRobot.java | 6 +-- .../keywords/Keywords/PointLocation.java | 2 +- .../keywords/Keywords/ScrollRobot.java | 4 +- .../matchers/InstanceOfMatcher.java | 2 +- .../matchers/ProgressBarMatchers.java | 21 +++------- .../javafxlibrary/utils/HelperFunctions.java | 40 +++++++++---------- .../java/javafxlibrary/utils/Session.java | 4 +- .../javafxlibrary/utils/TestFxAdapter.java | 4 +- src/main/java/libdoc-documentation.txt | 10 ++--- .../acceptance/DatePickerTest.robot | 4 +- .../acceptance/MenuAppTest.robot | 8 ++-- .../robotframework/acceptance/MiscTests.robot | 6 +-- .../SwingApplicationWrapperTest.robot | 2 +- .../acceptance/WindowLookupTest.robot | 2 +- .../acceptance/WindowManagementTest.robot | 14 +++---- src/test/robotframework/resource.robot | 5 ++- 24 files changed, 110 insertions(+), 119 deletions(-) diff --git a/pom.xml b/pom.xml index cacd1bf..147e345 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.apache.maven.plugins maven-source-plugin - 3.1.0 + 3.2.1 attach-sources @@ -93,7 +93,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + 3.2.0 attach-javadocs @@ -107,7 +107,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.0.0 + 3.2.0 attach-artifacts @@ -195,7 +195,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.8 true ossrh @@ -233,7 +233,7 @@ maven-assembly-plugin - 3.2.0 + 3.3.0 package @@ -256,7 +256,7 @@ org.robotframework robotframework-maven-plugin - 1.5.1 + 1.7.1 acceptance tests @@ -316,7 +316,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.1 + 3.2.4 package @@ -366,7 +366,7 @@ org.apache.maven maven-model - 3.6.2 + 3.6.3 org.jmockit @@ -377,7 +377,7 @@ junit junit - 4.12 + 4.13 org.testfx @@ -397,7 +397,7 @@ org.robotframework robotframework - 3.1.2 + 3.2.1 org.hamcrest @@ -407,7 +407,7 @@ com.google.guava guava - 28.1-jre + 29.0-jre org.robotframework @@ -417,12 +417,12 @@ org.apache.commons commons-lang3 - 3.9 + 3.11 commons-io commons-io - 2.6 + 2.7 diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 6141c68..63523a9 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -224,14 +224,14 @@ public String getKeywordDocumentation(String keywordName) { return FileUtils.readFileToString(new File("./src/main/java/libdoc-documentation.txt"), "utf-8"); } catch (IOException e) { e.printStackTrace(); - return "IOException occured while reading the documentation file!"; + return "IOException occurred while reading the documentation file!"; } } else if (keywordName.equals("__init__")) { try { return FileUtils.readFileToString(new File("./src/main/java/libdoc-init-documentation.txt"), "utf-8"); } catch (IOException e) { e.printStackTrace(); - return "IOException occured while reading the init documentation file!"; + return "IOException occurred while reading the init documentation file!"; } } else { try { diff --git a/src/main/java/JavaFXLibraryRemoteServer.java b/src/main/java/JavaFXLibraryRemoteServer.java index 17dbc9a..cab0435 100644 --- a/src/main/java/JavaFXLibraryRemoteServer.java +++ b/src/main/java/JavaFXLibraryRemoteServer.java @@ -29,8 +29,6 @@ public JavaFXLibraryRemoteServer(int port) { super(port); } - private static Log log = LogFactory.getLog(RemoteServer.class); - public static void configureLogging() { Configurator.initialize(new DefaultConfiguration()); Configurator.setRootLevel(Level.FATAL); @@ -38,6 +36,6 @@ public static void configureLogging() { LogFactory.releaseAll(); LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger"); - log = LogFactory.getLog(RemoteServer.class); + Log log = LogFactory.getLog(RemoteServer.class); } } \ No newline at end of file diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java index 0fff3ec..5d40723 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java @@ -85,7 +85,7 @@ public void bringStageToFront(Stage stage) { RobotLog.info("Bringing following Stage to front: \"" + stage + "\""); try { robot.targetWindow(stage); - Platform.runLater(() -> stage.toFront()); + Platform.runLater(stage::toFront); } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Unable to bring stage to front.", e); } @@ -251,7 +251,7 @@ public String[] listNodeMethods(Node node) { RobotLog.info("Listing all available methods for node: \"" + node + "\""); try { Class klass = node.getClass(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); System.out.println("*INFO*"); while (klass != null) { String name = String.format("\n*%s*\n", klass.getName()); @@ -264,21 +264,21 @@ public String[] listNodeMethods(Node node) { } klass = klass.getSuperclass(); } - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Listing node methods failed.", e); } } private String getMethodDescription(Method m) { - String entry = m.getReturnType().getName() + " "; - entry += m.getName(); - entry += "("; + 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 += args[i].getName(); + entry.append(args[i].getName()); if (i != args.length - 1) - entry += ", "; + entry.append(", "); } return entry + ")"; } @@ -405,12 +405,11 @@ public Set getNodeChildrenByClassName(Object locator, String className) Node node = objectToNode(locator); RobotLog.info("Getting node: \"" + node + "\" children by class name: \"" + className + "\""); try { - Set keys = new HashSet(); + Set keys = new HashSet<>(); Set childNodes = node.lookupAll("*"); - Iterator iter = childNodes.iterator(); - while (iter.hasNext()) { - Node childNode = (Node) iter.next(); + for (Object o : childNodes) { + Node childNode = (Node) o; if (childNode.getClass().getSimpleName().equals(className)) { RobotLog.trace("Classname: \"" + className + "\" found: \"" + childNode + "\""); keys.add(mapObject(childNode)); @@ -455,7 +454,7 @@ public String getNodeHeight(Object locator) { for (Method m : methods) { if (m.getName().equals("getHeight")) { try { - Object result = m.invoke(node, null); + Object result = m.invoke(node, (Object) null); return result.toString(); } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Problem calling method: .getHeight(): " + e.getMessage(), e); @@ -486,7 +485,7 @@ public String getNodeImageUrl(Object locator) { if (m.getName().equals("getImage") && m.getParameterCount() == 0) { RobotLog.trace("Method getImage() found. Invoking it on node: \"" + node + "\""); try { - Object result = m.invoke(node, null); + 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(); @@ -594,7 +593,7 @@ public String getWindowTitle(Object object) { try { Method m = object.getClass().getMethod("getTitle"); - return (String) m.invoke(object, null); + return (String) m.invoke(object, (Object[]) null); } catch (NoSuchMethodException e) { RobotLog.info("This window type has no getTitle() -method. Returning null"); return ""; @@ -700,7 +699,7 @@ public List getTableColumnCells(Object locator, int column) { 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)); + RobotLog.info("Index number: " + i); columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column))); } @@ -867,7 +866,7 @@ public Object getSelectedRadioButton(Object locator) { try{ RadioButton rb = (RadioButton)objectToNode(locator); - return (Node)rb.getToggleGroup().getSelectedToggle(); + return rb.getToggleGroup().getSelectedToggle(); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as RadioButton!"); @@ -998,7 +997,7 @@ public Double getScrollPaneHorizontalValue(Object locator){ } } - @RobotKeyword("Returns the selected date from given datepicker element\n\n" + @RobotKeyword("Returns the selected date from given DatePicker element\n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the DatePicker element, see " + "`3. Locating JavaFX Nodes`. \n\n" + "\nExample:\n" @@ -1098,7 +1097,7 @@ public void waitForEventsInFxApplicationThread(int timeout) { final Throwable[] threadException = new JavaFXLibraryNonFatalException[1]; try { Semaphore semaphore = new Semaphore(0); - Platform.runLater(() -> semaphore.release()); + Platform.runLater(semaphore::release); Thread t = new Thread(() -> { int passed = 0; try { diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java index 81ee431..6e08c68 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java @@ -30,9 +30,6 @@ @RobotKeywords public class RunOnFailure extends TestFxAdapter{ - // The keyword to run an failure - private String runOnFailureKeyword = "Take Screenshot"; - // Only run keyword on failure if false private static boolean runningOnFailureRoutine = false; @@ -49,6 +46,8 @@ public class RunOnFailure extends TestFxAdapter{ public void runOnFailure() { + // The keyword to run an failure + String runOnFailureKeyword = "Take Screenshot"; RobotLog.debug("Executing cleanup functions by running: " + runOnFailureKeyword); RobotLog.debug("runningOnFailureRoutine: " + runningOnFailureRoutine); diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java index fd5fabe..869fdaa 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java @@ -40,7 +40,7 @@ import org.testfx.service.support.impl.PixelMatcherRgb; import org.hamcrest.core.IsNot; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import static org.testfx.api.FxAssert.verifyThat; import static org.testfx.matcher.base.NodeMatchers.*; import static javafxlibrary.utils.HelperFunctions.*; @@ -330,9 +330,9 @@ public void boundsShouldBeEqual(Bounds firstBounds, Bounds secondBounds) { RobotLog.info("Checking if \"" + firstBounds + "\" equals with \"" + secondBounds + "\"."); if (firstBounds == null || secondBounds == null ) throw new JavaFXLibraryNonFatalException("One of the bounds is null. Check log for additional info."); - assertTrue("Expected bounds to be equal:\n" + assertEquals("Expected bounds to be equal:\n" + " First bound: " + firstBounds + "\n" - + " Second bound: " + secondBounds, firstBounds.equals(secondBounds)); + + " Second bound: " + secondBounds, firstBounds, secondBounds); } @RobotKeyword("Checks if given two bounds are not equal. \n\n" @@ -343,9 +343,9 @@ public void boundsShouldNotBeEqual(Bounds firstBounds, Bounds secondBounds) { RobotLog.info("Checking if \"" + firstBounds + "\" are not equal with \"" + secondBounds + "\"."); if (firstBounds == null || secondBounds == null ) throw new JavaFXLibraryNonFatalException("One of the bounds is null. Check log for additional info."); - assertTrue("Expected bounds to be not equal:\n" + assertNotEquals("Expected bounds to be not equal:\n" + " First bound: " + firstBounds + "\n" - + " Second bound: " + secondBounds, !firstBounds.equals(secondBounds)); + + " Second bound: " + secondBounds, firstBounds, secondBounds); } @RobotKeyword("Fails if images are not similar enough\n\n" @@ -443,6 +443,7 @@ public static void toggleButtonShouldNotBeSelected(Object locator) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as ToggleButton!"); } } + @RobotKeyword("Waits until given ProgressBar is finished or timeout expires. \n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the ToggleButton element, see " + " `3. Locating JavaFX Nodes`. \n\n" diff --git a/src/main/java/javafxlibrary/keywords/Keywords/BoundsLocation.java b/src/main/java/javafxlibrary/keywords/Keywords/BoundsLocation.java index 41950c7..71617ca 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/BoundsLocation.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/BoundsLocation.java @@ -86,7 +86,7 @@ public Object createPoint(double x, double y) { @ArgumentNames({"minX", "minY", "width", "height"}) public Object createRectangle(double minX, double minY, double width, double height) { try { - RobotLog.info("Creating retangle object with minX=\"" + minX + "\", minY=\"" + minY + "\", width=\"" + + RobotLog.info("Creating rectangle object with minX=\"" + minX + "\", minY=\"" + minY + "\", width=\"" + width + "\" and height=\"" + height + "\""); return mapObject(new Rectangle2D(minX, minY, width, height)); } catch (Exception e) { diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ClickRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/ClickRobot.java index 90c36e5..33f7dfe 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ClickRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ClickRobot.java @@ -150,7 +150,7 @@ public FxRobotInterface clickOnCoordinates(int x, int y, String motion) { checkClickLocation(x, y); try { - return robot.clickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY); + return robot.clickOn(x, y, getMotion(motion), MouseButton.PRIMARY); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) { throw e; @@ -167,7 +167,7 @@ public FxRobotInterface doubleClickOnCoordinates(int x, int y, String motion) { checkClickLocation(x, y); try { RobotLog.info("Double clicking on coordinates x=\"" + x + "\"" + ", y=\"" + y + "\"" + " and motion=\"" + motion + "\""); - return robot.doubleClickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY); + return robot.doubleClickOn(x, y, getMotion(motion), MouseButton.PRIMARY); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) { throw e; @@ -184,7 +184,7 @@ public FxRobotInterface rightClickOnCoordinates(int x, int y, String motion) { checkClickLocation(x, y); try { RobotLog.info("Right clicking on coordinates x=\"" + x + "\"" + ", y=\"" + y + "\"" + " and motion=\"" + motion + "\""); - return robot.rightClickOn((double) x, (double) y, getMotion(motion)); + return robot.rightClickOn(x, y, getMotion(motion)); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) { throw e; diff --git a/src/main/java/javafxlibrary/keywords/Keywords/DragRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/DragRobot.java index f6452a6..f4d66e3 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/DragRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/DragRobot.java @@ -113,7 +113,7 @@ public FxRobotInterface dropBy(int x, int y) { try { RobotLog.info("Dropping by x=\"" + x + "\" and y=\"" + y + "\""); - return robot.dropBy((double) x, (double) y); + return robot.dropBy(x, y); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) { throw e; @@ -134,7 +134,7 @@ public FxRobotInterface dropBy(int x, int y) { public FxRobotInterface dragFromCoordinates(int x, int y, String... buttons) { try { RobotLog.info("Dragging from x=\"" + x + "\" and y=\"" + y + "\" with buttons \"" + Arrays.toString(buttons) + "\""); - return robot.drag((double) x, (double) y, HelperFunctions.getMouseButtons(buttons)); + return robot.drag(x, y, HelperFunctions.getMouseButtons(buttons)); } catch (Exception e) { if (e instanceof JavaFXLibraryNonFatalException) { throw e; @@ -153,7 +153,7 @@ public FxRobotInterface dragFromCoordinates(int x, int y, String... buttons) { public FxRobotInterface dropToCoordinates(int x, int y) { try { RobotLog.info("Dropping to x=\"" + x + "\" and y=\"" + y + "\""); - return robot.dropTo((double) x, (double) y); + return robot.dropTo(x, y); } catch (Exception e) { if ( e instanceof JavaFXLibraryNonFatalException ) { throw e; diff --git a/src/main/java/javafxlibrary/keywords/Keywords/PointLocation.java b/src/main/java/javafxlibrary/keywords/Keywords/PointLocation.java index 99eed6e..b867321 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/PointLocation.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/PointLocation.java @@ -68,7 +68,7 @@ public Object pointTo(Object locator) { public Object pointToCoordinates(int x, int y) { try { RobotLog.info("Returning a pointquery to coordinates: [" + x + ", " + y + "]"); - return HelperFunctions.mapObject(robot.point((double) x, (double) y)); + return HelperFunctions.mapObject(robot.point(x, y)); } catch (Exception e) { if(e instanceof JavaFXLibraryNonFatalException) throw e; diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScrollRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/ScrollRobot.java index 735d121..0f6febc 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScrollRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScrollRobot.java @@ -38,7 +38,7 @@ public class ScrollRobot extends TestFxAdapter { @ArgumentNames({ "direction", "amount=1" }) public void scrollVertically(String direction, int amount) { try { - RobotLog.info("Scrolling \"" + direction + "\" by \"" + Integer.toString(amount) + "\" ticks."); + RobotLog.info("Scrolling \"" + direction + "\" by \"" + amount + "\" ticks."); robot.scroll(amount, HelperFunctions.getVerticalDirection(direction)); } catch (Exception e) { if(e instanceof JavaFXLibraryNonFatalException) @@ -62,7 +62,7 @@ public void scrollVertically(String direction, int amount) { public void scrollHorizontally(String direction, int amount) { try { - RobotLog.info("Scrolling \"" + direction + "\" by \"" + Integer.toString(amount) + "\" ticks."); + RobotLog.info("Scrolling \"" + direction + "\" by \"" + amount + "\" ticks."); robot.press(KeyCode.SHIFT); robot.scroll(amount, HelperFunctions.getHorizontalDirection(direction)); robot.release(KeyCode.SHIFT); diff --git a/src/main/java/javafxlibrary/matchers/InstanceOfMatcher.java b/src/main/java/javafxlibrary/matchers/InstanceOfMatcher.java index ee6fae9..923e238 100644 --- a/src/main/java/javafxlibrary/matchers/InstanceOfMatcher.java +++ b/src/main/java/javafxlibrary/matchers/InstanceOfMatcher.java @@ -41,7 +41,7 @@ public InstanceOfMatcher(String name) throws ClassNotFoundException { @Override public void describeTo(Description description) { if (last != null) { - description.appendText(String.format("Expected type %s%n but got ", type, last)); + description.appendText("Expected type " + type + " but got " + last); } } diff --git a/src/main/java/javafxlibrary/matchers/ProgressBarMatchers.java b/src/main/java/javafxlibrary/matchers/ProgressBarMatchers.java index d373c26..7bf3e38 100644 --- a/src/main/java/javafxlibrary/matchers/ProgressBarMatchers.java +++ b/src/main/java/javafxlibrary/matchers/ProgressBarMatchers.java @@ -49,36 +49,27 @@ public void describeMismatch(Object object, Description description) { } public static Matcher isComplete() { - return progressMatcher("finished", pb -> complete(pb), "not finished!" ); + return progressMatcher("finished", ProgressBarMatchers::complete, "not finished!" ); } public static Matcher isLessThan(Double value) { - return progressMatcher("less than " + Double.toString(value), pb -> lessThan(pb, value), "not less than " + Double.toString(value) ); + return progressMatcher("less than " + value, pb -> lessThan(pb, value), "not less than " + value); } public static Matcher isMoreThan(Double value) { - return progressMatcher("more than " + Double.toString(value), pb -> moreThan(pb, value), "not more than " + Double.toString(value) ); + return progressMatcher("more than " + value, pb -> moreThan(pb, value), "not more than " + value); } private static boolean complete(ProgressBar pb) { - if(pb.getProgress() == 1d ) - return true; - else - return false; + return pb.getProgress() == 1d; } private static boolean lessThan(ProgressBar pb, Double value) { - if(pb.getProgress() <= value ) - return true; - else - return false; + return pb.getProgress() <= value; } private static boolean moreThan(ProgressBar pb, Double value) { - if(pb.getProgress() >= value ) - return true; - else - return false; + return pb.getProgress() >= value; } diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index 3648c87..1c82fc3 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -85,14 +85,10 @@ public static Node waitUntilExists(String target, int timeout, String timeUnit) + timeout + ", timeUnit=" + timeUnit); try { - waitFor(timeout, getTimeUnit(timeUnit), () -> { - return asyncFx(() -> createFinder().find(target) != null).get(); - }); + waitFor(timeout, getTimeUnit(timeUnit), () -> asyncFx(() -> createFinder().find(target) != null).get()); Node node = asyncFx(() -> createFinder().find(target)).get(); // TODO: Add null checks for node.getScene() - waitFor(timeout, getTimeUnit(timeUnit), () -> { - return asyncFx(() -> hasValidCoordinates(node)).get(); - }); + waitFor(timeout, getTimeUnit(timeUnit), () -> asyncFx(() -> hasValidCoordinates(node)).get()); waitForFxEvents(); return node; } catch (JavaFXLibraryNonFatalException nfe) { @@ -102,7 +98,7 @@ public static Node waitUntilExists(String target, int timeout, String timeUnit) + timeout + " " + timeUnit); } catch (Exception e) { RobotLog.trace("Exception in waitUntilExists: " + e + "\n" + e.getCause().toString()); - throw new JavaFXLibraryNonFatalException("waitUntilExist failed: ", e); + throw new JavaFXLibraryNonFatalException("Given element \"" + target + "\" was not found.", e); } } @@ -111,9 +107,7 @@ public static void waitUntilDoesNotExists(String target, int timeout, String tim + timeout + ", timeUnit=" + timeUnit); try { - waitFor(timeout, getTimeUnit(timeUnit), () -> { - return asyncFx(() -> createFinder().find(target) == null).get(); - }); + waitFor(timeout, getTimeUnit(timeUnit), () -> asyncFx(() -> createFinder().find(target) == null).get()); waitForFxEvents(); } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -122,7 +116,7 @@ public static void waitUntilDoesNotExists(String target, int timeout, String tim + timeout + " " + timeUnit); } catch (Exception e) { RobotLog.trace("Exception in waitUntilDoesNotExists: " + e + "\n" + e.getCause().toString()); - throw new JavaFXLibraryNonFatalException("waitUntilDoesNotExist failed: ", e); + throw new JavaFXLibraryNonFatalException("Given element \"" + target + "\" was still found.", e); } } @@ -137,7 +131,7 @@ public static Node waitUntilVisible(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes visible, timeout=" + timeout); try { - waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isVisible()).matches(finalTarget)); + waitFor(timeout, TimeUnit.SECONDS, () -> Matchers.is(isVisible()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -159,7 +153,7 @@ public static Node waitUntilInvisible(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes invisible, timeout=" + timeout); try { - waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isInvisible()).matches(finalTarget)); + waitFor(timeout, TimeUnit.SECONDS, () -> Matchers.is(isInvisible()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -180,7 +174,7 @@ public static Node waitUntilEnabled(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes enabled, timeout=" + timeout); try { - waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isEnabled()).matches(finalTarget)); + waitFor(timeout, TimeUnit.SECONDS, () -> Matchers.is(isEnabled()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -201,7 +195,7 @@ public static Node waitUntilDisabled(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes disabled, timeout=" + timeout); try { - waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isDisabled()).matches(finalTarget)); + waitFor(timeout, TimeUnit.SECONDS, () -> Matchers.is(isDisabled()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -215,7 +209,7 @@ public static Node waitUntilDisabled(Object target, int timeout) { public static void waitForProgressBarToFinish(ProgressBar pb, int timeout) { try { - waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(ProgressBarMatchers.isComplete()).matches(pb)); + waitFor(timeout, TimeUnit.SECONDS, () -> Matchers.is(ProgressBarMatchers.isComplete()).matches(pb)); } catch (TimeoutException te) { throw new JavaFXLibraryNonFatalException("Given ProgressBar did not complete in " + timeout + " seconds!"); } @@ -453,9 +447,12 @@ public static void deleteScreenshotsFrom(String path) { try { File directory = new File(path); File[] fileList = directory.listFiles(); + assert fileList != null; for (File file : fileList) { if (file.getName().endsWith(".png")) - file.delete(); + if (!file.delete()) { + RobotLog.warn("Screenshot \"" + file.getAbsolutePath() + "\" deletion failed."); + } } } catch (NullPointerException e) { System.out.println("No directory found at " + path); @@ -466,9 +463,12 @@ public static void deleteScreenshotsFrom(String path, String regex) { try { File directory = new File(path); File[] fileList = directory.listFiles(); + assert fileList != null; for (File file : fileList) { if (file.getName().endsWith(".png") && file.getName().contains(regex)) - file.delete(); + if (!file.delete()) { + RobotLog.warn("Screenshot \"" + file.getAbsolutePath() + "\" deletion failed."); + } } } catch (NullPointerException e) { System.out.println("No directory found at " + path); @@ -678,7 +678,7 @@ public static Node findNode(Node node, String query) { return findNode(nodelist.get(getQueryIndex(currentQuery)), nextQuery); } else { // no index given, continue search with all matches - Node newNode = null; + Node newNode; for (Node n : nodelist) { newNode = findNode(n, nextQuery); @@ -775,7 +775,7 @@ public static void printFields(Object o, Class c) { System.out.println("
  • " + field.getName() + " : " + field.get(o) + "
  • "); } System.out.println(""); - System.out.println(""); + System.out.println(); } if (c.getSuperclass() != null) { diff --git a/src/main/java/javafxlibrary/utils/Session.java b/src/main/java/javafxlibrary/utils/Session.java index 5554031..de9e0d0 100644 --- a/src/main/java/javafxlibrary/utils/Session.java +++ b/src/main/java/javafxlibrary/utils/Session.java @@ -35,8 +35,8 @@ public class Session { public Stage primaryStage; public FxRobot sessionRobot; public Application sessionApplication; - public String applicationName = null; - public String screenshotDirectory = null; + public String applicationName; + public String screenshotDirectory; public Session(String appName, String... appArgs) { try { diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 3fd7b45..9220d86 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -91,7 +91,9 @@ public void setCurrentSessionScreenshotDirectory(String dir){ if (activeSession != null) { File errDir = new File(dir); if (!errDir.exists()) - errDir.mkdirs(); + if(!errDir.mkdirs()) { + RobotLog.warn("Screenshot directory \"" + dir + "\" creation failed!"); + } activeSession.screenshotDirectory = dir; } else { throw new JavaFXLibraryNonFatalException("Unable to set screenshot directory, no application is currently open!"); diff --git a/src/main/java/libdoc-documentation.txt b/src/main/java/libdoc-documentation.txt index 620f0c9..eb31ed2 100644 --- a/src/main/java/libdoc-documentation.txt +++ b/src/main/java/libdoc-documentation.txt @@ -140,11 +140,11 @@ object methods available for Nodes. Let's take an example of a table that can contain complex objects, not just simple string values: | *Return value* | *Keyword* | *Argument* | *Argument* | *Description* | | ${table cells}= | Get Table Row Cells | \#table-id | 2 | # table cell Nodes are stored in map and string representations are returned | -| | Node Should Be Enabled | @{table cells}[column 0] | | # Library takes the string value as an argument and converts it back to Node | -| | Node Should Have Text | @{table cells}[column 1] | some text | | | -| | Click On | @{table cells}[column 2] | | # in case this cell is clickable | -| ${cell buttons}= | Find All From Node | @{table cells}[column 3] | .button | # Finds all buttons from table cell Node | -| | Click On | @{cell buttons}[0] | | | +| | Node Should Be Enabled | ${table cells}[column 0] | | # Library takes the string value as an argument and converts it back to Node | +| | Node Should Have Text | ${table cells}[column 1] | some text | | | +| | Click On | ${table cells}[column 2] | | # in case this cell is clickable | +| ${cell buttons}= | Find All From Node | ${table cells}[column 3] | .button | # Finds all buttons from table cell Node | +| | Click On | ${cell buttons}[0] | | | Most of the JavaFXLibrary keywords can use locators directly e.g. `Click On` keyword can take just css selector as an argument, but in some cases it can be convenient to be able to pass in a 'Node' as an argument, especially when dealing with complex data structures. diff --git a/src/test/robotframework/acceptance/DatePickerTest.robot b/src/test/robotframework/acceptance/DatePickerTest.robot index df9c699..dce0a2d 100644 --- a/src/test/robotframework/acceptance/DatePickerTest.robot +++ b/src/test/robotframework/acceptance/DatePickerTest.robot @@ -48,9 +48,9 @@ Teardown test case Set Year [Arguments] ${year} ${time_labels} Find All css=.spinner-label - ${year_label} Set Variable @{time_labels}[1] + ${year_label} Set Variable ${time_labels}[1] ${left_arrows} Find All css=.left-button - ${prev_year} Set Variable @{left_arrows}[1] + ${prev_year} Set Variable ${left_arrows}[1] FOR ${i} IN RANGE 99 ${current} Get Node Text ${year_label} Exit For Loop If ${current} == ${year} diff --git a/src/test/robotframework/acceptance/MenuAppTest.robot b/src/test/robotframework/acceptance/MenuAppTest.robot index 4b909f9..f617b53 100644 --- a/src/test/robotframework/acceptance/MenuAppTest.robot +++ b/src/test/robotframework/acceptance/MenuAppTest.robot @@ -52,7 +52,7 @@ Menus - Change Theme Click On text="JavaFX" HORIZONTAL_FIRST ${SCENE} Get Scene css=.textLabel @{STYLESHEET} Call Object Method ${SCENE} getStylesheets - Should Contain @{STYLESHEET}[0] Javastyle.css + Should Contain ${STYLESHEET}[0] Javastyle.css Menus - Change Font Size [Tags] smoke demo-set @@ -71,16 +71,16 @@ Combined Click On text="Gradient" HORIZONTAL_FIRST ${SCENE} Get Scene css=.textLabel @{STYLESHEET} Call Object Method ${SCENE} getStylesheets - Should Contain @{STYLESHEET}[0] Gradientstyle.css + Should Contain ${STYLESHEET}[0] Gradientstyle.css Click On text="Services" Click On text="Analyze" Verify String css=.textLabel Analyze # Using Find All instead of text-value based css-selector here to avoid dependencies with the second test case @{COMBOBOXES} Find All css=.combo-box - Click On @{COMBOBOXES}[0] + Click On ${COMBOBOXES}[0] Click On text="25 pc" - Click On @{COMBOBOXES}[1] + Click On ${COMBOBOXES}[1] Click On text="50 €" Verify String id=total 1250 € diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 14063e0..3913494 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -149,8 +149,8 @@ Find All From Node ${ROOT} Get Root Node Of ${YELLOW} ${RESULT} Call Object Method ${ROOT} lookup HBox VBox HBox VBox HBox @{RECT} Find All css=Rectangle root=${RESULT} - Should Be Equal ${YELLOW} @{RECT}[0] - Should Be Equal ${VIOLET} @{RECT}[1] + Should Be Equal ${YELLOW} ${RECT}[0] + Should Be Equal ${VIOLET} ${RECT}[1] Get Node Children By Class Name [Tags] smoke @@ -242,7 +242,7 @@ Find All With Pseudo Class ${NODE} Find id=rightClickButton Move To ${NODE} @{LIST} Find All css=HBox pseudo=hover failIfNotFound=True - Should Be Equal ${NODE} @{LIST}[0] + Should Be Equal ${NODE} ${LIST}[0] Get Table Column Count [Tags] smoke diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 09ae44b..456545f 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -16,7 +16,7 @@ Swing Embedded JavaFX Click Test Text Value Should Be Swing Embedded JavaFX FOR ${I} IN RANGE 0 5 Click On css=.button - Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be @{colors}[${i}] + Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be ${colors}[${i}] END Swing Embedded JavaFX Type Test diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index 7efcb68..93ed43e 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -100,7 +100,7 @@ Close Current Window [Tags] smoke set-todo Run Keyword If ${headless} Set Tags monocle-issue ${START} List Windows - Activate window @{START}[0] + Activate window ${START}[0] Close Current Window ${END} List Windows Should Not Be Equal ${START} ${END} msg=Unable to close window! values=False diff --git a/src/test/robotframework/acceptance/WindowManagementTest.robot b/src/test/robotframework/acceptance/WindowManagementTest.robot index 82d924f..3c05a26 100644 --- a/src/test/robotframework/acceptance/WindowManagementTest.robot +++ b/src/test/robotframework/acceptance/WindowManagementTest.robot @@ -27,8 +27,8 @@ Add an employee Click On id=navigationDialog Click On id=addEmployeeButton ${TEXTFIELDS} Find All css=.dialog-pane .text-field - Write To @{TEXTFIELDS}[0] Pasi - Write To @{TEXTFIELDS}[1] 1452754765 + Write To ${TEXTFIELDS}[0] Pasi + Write To ${TEXTFIELDS}[1] 1452754765 Click On text="Add" Employee Should Be Added Pasi 1452754765 @@ -39,8 +39,8 @@ Add Multiple Employees FOR ${ITEM} IN @{DATA} Click On text="Add employee" ${FIELDS} Find All css=.dialog-pane .text-field - Write To @{FIELDS}[0] ${ITEM.name} - Write To @{FIELDS}[1] ${ITEM.phone} + Write To ${FIELDS}[0] ${ITEM.name} + Write To ${FIELDS}[1] ${ITEM.phone} Click On text="Add" Employee Should Be Added ${ITEM.name} ${ITEM.phone} END @@ -58,7 +58,7 @@ Find All From Node Click On id=navigationDialog ${NODE} Find id=secondRow ${TEXTFIELDS} Find All css=.employeeDataCell failIfNotFound=True root=${NODE} - ${PHONE} Set Variable @{TEXTFIELDS}[1] + ${PHONE} Set Variable ${TEXTFIELDS}[1] ${RESULT} Call Object Method ${PHONE} getText Should Be Equal ${RESULT} 0401231234 @@ -74,8 +74,8 @@ Employee Should Be Added ${SIZE} Get Length ${CELLS} ${NAMEINDEX} Evaluate ${SIZE}-${2} ${PHONEINDEX} Evaluate ${SIZE}-${1} - ${NAMELABEL} Set Variable @{CELLS}[${NAMEINDEX}] - ${PHONELABEL} Set Variable @{CELLS}[${PHONEINDEX}] + ${NAMELABEL} Set Variable ${CELLS}[${NAMEINDEX}] + ${PHONELABEL} Set Variable ${CELLS}[${PHONEINDEX}] ${NAMEVALUE} Call Object Method ${NAMELABEL} getText ${PHONEVALUE} Call Object Method ${PHONELABEL} getText Should Be Equal ${NAME} ${NAMEVALUE} diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 76d4023..a7b2b71 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -10,8 +10,9 @@ Import JavaFXLibrary Set To Classpath ${appJar} Disable Embedded Image Logging For Negative Tests - :FOR ${tag} IN @{TEST TAGS} - \ Run Keyword If '${tag}' == 'negative' Set Image Logging DISKONLY + FOR ${tag} IN @{TEST TAGS} + Run Keyword If '${tag}' == 'negative' Set Image Logging DISKONLY + END Enable Image Logging Set Image Logging EMBEDDED From a823553b3dc1df9561353ece72c6c1f180f95570 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 20:06:14 +0300 Subject: [PATCH 08/20] fix pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 147e345..1aeb927 100644 --- a/pom.xml +++ b/pom.xml @@ -232,6 +232,7 @@ + org.apache.maven.plugins maven-assembly-plugin 3.3.0 From 6e08488934330ac5bca062d5fd32e666ddcb5ac5 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 20:08:53 +0300 Subject: [PATCH 09/20] 0.5.5 release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c236ecc..f72b475 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.4 + 0.5.5 UTF-8 1.44 From 356b68894eb2d87b2dbf073f42ae0b7e65870615 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 31 Aug 2020 20:42:39 +0300 Subject: [PATCH 10/20] update documentation and links in README.md --- README.md | 4 ++-- docs/javafxlibrary.html | 39 ++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index aea0021..ca0ef26 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ JavaFXLibrary works with both Jython (local and remote use) and Python (remote o JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. ## Keyword documentation -See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.4/javafxlibrary-0.5.4.html). +See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.5/javafxlibrary-0.5.5.html). -For editors (IDEs) keyword documentation can be obtained from [here](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.4/javafxlibrary-0.5.4.xml). +For editors (IDEs) keyword documentation can be obtained from [here](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.5/javafxlibrary-0.5.5.xml). ## Taking the library into use ### As a local library diff --git a/docs/javafxlibrary.html b/docs/javafxlibrary.html index 6f66307..4d2a8d7 100644 --- a/docs/javafxlibrary.html +++ b/docs/javafxlibrary.html @@ -5,7 +5,7 @@ - +