diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java index 1e8c896..1540b7a 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java @@ -235,6 +235,17 @@ public void clearObjectMap() { @RobotKeyword("Returns the class name of currently active JavaFX Application") + public String getCurrentApplication() { + try { + return getCurrentSessionApplicationName(); + } catch (Exception e) { + throw new JavaFXLibraryNonFatalException("Problem getting current application name.", e); + } + } + + @Deprecated + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Get Current Application` keyword instead.\n\n" + + "Returns the class name of currently active JavaFX Application\n") public String currentApplication() { try { return getCurrentSessionApplicationName(); @@ -242,4 +253,5 @@ public String currentApplication() { throw new JavaFXLibraryNonFatalException("Problem getting current application name.", e); } } + } diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java index b38c79e..90231f6 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java @@ -56,7 +56,7 @@ public class ConvenienceKeywords extends TestFxAdapter { @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n" + + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" + "finder that mimics _xpath_ style search.\n\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and " @@ -139,7 +139,7 @@ public void callObjectMethodInFxApplicationThread(Object object, String method, } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" + "Returns the *first* node matching the query. \n\n" + "``query`` is the Class name String to use in lookup.\n" + "\nExample:\n" @@ -157,7 +157,7 @@ public Object findClass(final String query) { } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find All` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n\n" + "Returns *all* descendant nodes of given node matching the query. \n\n" + "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using objects`. \n\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" @@ -196,7 +196,7 @@ public List findAllFromNode(Object node, String query) { } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find All` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n\n" + "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" @@ -235,7 +235,7 @@ public List findAllWithPseudoClass(String query, String pseudo) { } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" + "Returns the *first* descendant node of given node matching the query. \n\n" + "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using objects`. \n\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" @@ -437,7 +437,7 @@ public Set getPseudoClassStates(Object locator) { // TODO: Should this be deleted? Find All From Node has the same functionality @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" + "Returns *all* descendant nodes of given node matching the given Java class name. \n\n" + "``locator`` is either a _query_ or _Object_ for node whose children will be queried, see " + "`3.2 Using locators as keyword arguments`. \n\n" @@ -488,7 +488,7 @@ public String getNodeText(Object locator) { } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Find` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" + "Returns height value of the node. \n\n" + "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see " + "`3. Locating or specifying UI elements`. \n\n") @@ -582,7 +582,7 @@ public String getObjectClassName(Object locator) { } @Deprecated - @RobotKeyword("*DEPRECATED!!* Use keyword `Get Scene` instead.\n\n" + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Get Scene` instead.\n\n" +"Returns given locators Scene object. \n\n" + "``locator`` is either a _query_ or a _Node_, see `3.2 Using locators as keyword arguments`\n\n") @ArgumentNames({ "locator" }) @@ -661,7 +661,7 @@ public Object getPrimaryScreenBounds() { @RobotKeyword("Returns the library version from POM file") public String getLibraryVersion() { - return HelperFunctions.loadRobotLibraryVersion(); + return HelperFunctions.getVersion(); } @RobotKeyword("Returns the value of cell in the given location\n\n" diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java index fa48610..d64be67 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java @@ -59,30 +59,64 @@ public class Verifiers extends TestFxAdapter { + "| Wait Until Element Exists | \\#some-node-id | 200 | MILLISECONDS | \n") @ArgumentNames({"locator", "timeout=10", "timeUnit=SECONDS"}) public Object waitUntilElementExists(String locator, int timeout, String timeUnit) { - RobotLog.info("Waiting until page contains element: \"" + locator + "\", timeout=\"" + timeout + "\", timeUnit= \"" + timeUnit + "\""); - try { + RobotLog.info("Waiting until page contains element: \"" + locator + "\", timeout=\"" + timeout + "\", timeUnit=\"" + timeUnit + "\"."); return mapObject(waitUntilExists(locator, timeout, timeUnit)); } catch (IllegalArgumentException | NullPointerException e) { throw new JavaFXLibraryNonFatalException("Something went wrong while waiting element \"" + locator + "\" to appear.", e ); } } + @RobotKeywordOverload + @ArgumentNames({"locator", "timeout"}) + public Object waitUntilElementExists(String locator, int timeout) { + return waitUntilElementExists(locator, timeout, "SECONDS"); + } + @RobotKeywordOverload @ArgumentNames({"locator"}) public Object waitUntilElementExists(String locator) { return waitUntilElementExists(locator, 10, "SECONDS"); } + @RobotKeyword("Waits until given element is not found.\n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the element, see " + + "`3. Locating or specifying UI elements`. \n\n" + + "``timeout`` is the maximum waiting time value, defaults to 10 \n\n" + + "``timeUnit`` is the time unit to be used, defaults to SECONDS, see `5. Used ENUMs` for more options for _timeUnit_. \n\n" + + "\nExample:\n" + + "| Wait Until Element Does Not Exists | \\#some-node-id | \n" + + "| Wait Until Element Does Not Exists | \\#some-node-id | 200 | MILLISECONDS | \n") + @ArgumentNames({"locator", "timeout=10", "timeUnit=SECONDS"}) + public void waitUntilElementDoesNotExists(String locator, int timeout, String timeUnit) { + try { + RobotLog.info("Waiting until page does not contains element: \"" + locator + "\", timeout=\"" + timeout + "\", timeUnit= \"" + timeUnit + "\"."); + waitUntilDoesNotExists(locator, timeout, timeUnit); + } catch (IllegalArgumentException | NullPointerException e) { + throw new JavaFXLibraryNonFatalException("Something went wrong while waiting element \"" + locator + "\" to disappear.", e ); + } + } + + @RobotKeywordOverload + @ArgumentNames({"locator", "timeout"}) + public void waitUntilElementDoesNotExists(String locator, int timeout) { + waitUntilElementDoesNotExists(locator, timeout, "SECONDS"); + } + + @RobotKeywordOverload + @ArgumentNames({"locator"}) + public void waitUntilElementDoesNotExists(String locator) { + waitUntilElementDoesNotExists(locator, 10, "SECONDS"); + } + @RobotKeyword("Waits until a node located by given locator becomes visible. \n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the element, see " + "`3. Locating or specifying UI elements`. \n\n" + "``timeout`` is the maximum waiting time in seconds, defaults to 5. \n\n") @ArgumentNames({"locator", "timeout=5"}) public void waitUntilNodeIsVisible(Object locator, int timeout) { - RobotLog.info("Waiting for node \"" + locator + "\" to be visible, timeout=\"" + timeout + "\""); - try { + RobotLog.info("Waiting for node \"" + locator + "\" to be visible, timeout=\"" + timeout + "\"."); waitUntilVisible(locator, timeout); } catch (IllegalArgumentException | NullPointerException e) { throw new JavaFXLibraryNonFatalException(""); @@ -95,15 +129,34 @@ public void waitUntilNodeIsVisible(Object locator) { waitUntilNodeIsVisible(locator, 5); } + @RobotKeyword("Waits until a node located by given locator becomes invisible. \n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the element, see " + + "`3. Locating or specifying UI elements`. \n\n" + + "``timeout`` is the maximum waiting time in seconds, defaults to 5. \n\n") + @ArgumentNames({"locator", "timeout=5"}) + public void waitUntilNodeIsNotVisible(Object locator, int timeout) { + try { + RobotLog.info("Waiting for node \"" + locator + "\" to be invisible, timeout=\"" + timeout + "\"."); + waitUntilInvisible(locator, timeout); + } catch (IllegalArgumentException | NullPointerException e) { + throw new JavaFXLibraryNonFatalException(""); + } + } + + @RobotKeywordOverload + @ArgumentNames({"locator"}) + public void waitUntilNodeIsNotVisible(Object locator) { + waitUntilNodeIsNotVisible(locator, 5); + } + @RobotKeyword("Waits until a node located using given locator becomes enabled. \n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the element, see " + "`3. Locating or specifying UI elements`. \n\n" + "``timeout`` is the maximum waiting time in seconds, defaults to 5. \n\n") @ArgumentNames({"locator", "timeout=5"}) public void waitUntilNodeIsEnabled(Object locator, int timeout) { - RobotLog.info("Waiting for node \"" + locator + "\" to be visible, timeout=\"" + timeout + "\""); - try { + RobotLog.info("Waiting for node \"" + locator + "\" to be enabled, timeout=\"" + timeout + "\"."); waitUntilEnabled(locator, timeout); } catch (IllegalArgumentException | NullPointerException e){ throw new JavaFXLibraryNonFatalException(""); @@ -116,11 +169,32 @@ public void waitUntilNodeIsEnabled(Object locator) { waitUntilNodeIsEnabled(locator, 5); } + @RobotKeyword("Waits until a node located using given locator becomes disabled. \n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the element, see " + + "`3. Locating or specifying UI elements`. \n\n" + + "``timeout`` is the maximum waiting time in seconds, defaults to 5. \n\n") + @ArgumentNames({"locator", "timeout=5"}) + public void waitUntilNodeIsNotEnabled(Object locator, int timeout) { + try { + RobotLog.info("Waiting for node \"" + locator + "\" to be disabled, timeout=\"" + timeout + "\"."); + waitUntilDisabled(locator, timeout); + } catch (IllegalArgumentException | NullPointerException e){ + throw new JavaFXLibraryNonFatalException(""); + } + } + + @RobotKeywordOverload + @ArgumentNames({"locator"}) + public void waitUntilNodeIsNotEnabled(Object locator) { + waitUntilNodeIsNotEnabled(locator, 5); + } + @RobotKeyword("Verifies that node is visible. \n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) public static void nodeShouldBeVisible(Object locator) { + RobotLog.info("Checking that locator node is visible: \"" + locator + "\"."); verifyThat(objectToNode(locator), isVisible() ); } @@ -128,6 +202,17 @@ public static void nodeShouldBeVisible(Object locator) { + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) + public static void nodeShouldNotBeVisible(Object locator) { + RobotLog.info("Checking that locator node is not visible: \"" + locator + "\"."); + verifyThat(objectToNode(locator), isInvisible() ); + } + + @Deprecated + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Node Should Not Be Visible` instead.\n\n" + + "Verifies that node is invisible. \n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + + "`3. Locating or specifying UI elements`. \n\n") + @ArgumentNames({ "locator" }) public static void nodeShouldBeInvisible(Object locator) { verifyThat(objectToNode(locator), isInvisible() ); } @@ -137,6 +222,7 @@ public static void nodeShouldBeInvisible(Object locator) { + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) public static void nodeShouldBeFocused(Object locator) { + RobotLog.info("Checking that locator node is focused: \"" + locator + "\"."); verifyThat(objectToNode(locator), isFocused() ); } @@ -145,6 +231,7 @@ public static void nodeShouldBeFocused(Object locator) { + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) public static void nodeShouldNotBeFocused(Object locator) { + RobotLog.info("Checking that locator node is not focused: \"" + locator + "\"."); verifyThat(objectToNode(locator), isNotFocused() ); } @@ -153,6 +240,7 @@ public static void nodeShouldNotBeFocused(Object locator) { + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) public static void nodeShouldBeEnabled(Object locator) { + RobotLog.info("Checking that locator node is enabled: \"" + locator + "\"."); verifyThat(objectToNode(locator), isEnabled() ); } @@ -160,6 +248,17 @@ public static void nodeShouldBeEnabled(Object locator) { + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) + public static void nodeShouldNotBeEnabled(Object locator) { + RobotLog.info("Checking that locator node is not enabled: \"" + locator + "\"."); + verifyThat(objectToNode(locator), NodeMatchers.isDisabled() ); + } + + @Deprecated + @RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Node Should Not Be Enabled` instead." + + "Verifies that node is disabled. \n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + + "`3. Locating or specifying UI elements`. \n\n") + @ArgumentNames({ "locator" }) public static void nodeShouldBeDisabled(Object locator) { verifyThat(objectToNode(locator), NodeMatchers.isDisabled() ); } @@ -170,22 +269,37 @@ public static void nodeShouldBeDisabled(Object locator) { @ArgumentNames({ "locator" }) public static void nodeShouldBeHoverable(Object locator) { try { + RobotLog.info("Checking that locator node is hoverable: \"" + locator + "\"."); verifyThat(objectToNode(locator), ExtendedNodeMatchers.isHoverable()); } catch (AssertionError ae){ Node node = getHoveredNode(); RobotLog.info("Given locator node: \"" + locator + "\" was not hoverable! Instead, following " + - "node was found: \"" + node + "\". See screenshot below: "); - new ScreenCapturing().captureImage(node); + "node was found: \"" + node + "\"."); throw ae; } } + @RobotKeyword("Verifies that node is not hoverable with mouse. \n\n" + + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + + "`3. Locating or specifying UI elements`. \n\n") + @ArgumentNames({ "locator" }) + public static void nodeShouldNotBeHoverable(Object locator) { + try { + RobotLog.info("Checking that locator node is not hoverable: \"" + locator + "\"."); + verifyThat(objectToNode(locator), ExtendedNodeMatchers.isHoverable()); + throw new JavaFXLibraryNonFatalException("Expected \"" + locator + "\" to be not hoverable - failed!"); + } catch (AssertionError ae){ + // Was not hoverable, keyword should pass + } + } + @RobotKeyword("Verifies that given node has text. \n\n" + "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see " + "`3. Locating or specifying UI elements`. \n\n" + "``text`` is the String to be searched for") @ArgumentNames({ "locator", "text" }) public static void nodeShouldHaveText(Object locator, String text) { + RobotLog.info("Checking that locator node \"" + locator + "\" has text \"" + text + "\"."); Object node = objectToNode(locator); if (node instanceof Text) @@ -204,6 +318,7 @@ else if (node instanceof TextFlow) + "``text`` is the String to be searched for") @ArgumentNames({ "locator", "text" }) public static void nodeShouldNotHaveText(Object locator, String text) { + RobotLog.info("Checking that locator node \"" + locator + "\" does not have text \"" + text + "\"."); Object node = objectToNode(locator); if (node instanceof Text) @@ -216,27 +331,70 @@ else if (node instanceof TextFlow) verifyThat((TextFlow) node, IsNot.not(TextFlowMatchers.hasText(text))); } - @RobotKeyword("Verifies that given window is showing. \n\n" + @RobotKeyword("Verifies that given window is visible.\n\n" + + "``window`` is the _Object:Window_ that specifies which window should be visible, see `3.2 Using objects`") + @ArgumentNames({ "window" }) + public static void windowShouldBeVisible(Object window) { + RobotLog.info("Checking if window \"" + window + "\" is visible."); + verifyThat((Window) window, WindowMatchers.isShowing()); + } + + @Deprecated + @RobotKeyword("*DEPRECATED in version 0.6.0!* Please use `Window Should Be Visible` instead.\n\n" +"Verifies that given window is showing. \n\n" + "``window`` is the _Object:Window_ that specifies which window should be showing, see `3.2 Using objects`") @ArgumentNames({ "window" }) public static void windowShouldBeShowing(Object window) { verifyThat((Window) window, WindowMatchers.isShowing()); } + @RobotKeyword("Verifies that given window is not visible.\n\n" + + "``window`` is the _Object:Window_ that specifies which window should be not visible, see `3.2 Using objects`") + @ArgumentNames({ "window" }) + public static void windowShouldNotBeVisible(Object window) { + RobotLog.info("Checking if window \"" + window + "\" is not visible."); + verifyThat((Window) window, WindowMatchers.isNotShowing()); + } + @RobotKeyword("Verifies that given window is focused. \n\n" + "``window`` is the _Object:Window_ that specifies which window should be focused, see `3.2 Using objects`") @ArgumentNames({ "window" }) public static void windowShouldBeFocused(Object window) { + RobotLog.info("Checking if window \"" + window + "\" is focused."); verifyThat((Window) window, WindowMatchers.isFocused()); } + @RobotKeyword("Verifies that given window is not focused. \n\n" + + "``window`` is the _Object:Window_ that specifies which window should be focused, see `3.2 Using objects`") + @ArgumentNames({ "window" }) + public static void windowShouldNotBeFocused(Object window) { + RobotLog.info("Checking if window \"" + window + "\" is not focused."); + verifyThat((Window) window, WindowMatchers.isNotFocused()); + } + @RobotKeyword("Checks if given two bounds are equal. \n\n" + "``firstBounds`` is an _Object:Bounds_ that specifies the first comparable Bounds\n\n" + "``secondBounds`` is an _Object:Bounds_ that specifies the second comparable Bounds, see `3.2 Using objects`") @ArgumentNames({ "firstBounds", "secondBounds" }) public void boundsShouldBeEqual(Bounds firstBounds, Bounds secondBounds) { - RobotLog.info("Checking if \"" + firstBounds + "\" equals with \"" + secondBounds + "\""); - assertTrue(firstBounds + " != " + secondBounds, firstBounds.equals(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" + + " First bound: " + firstBounds + "\n" + + " Second bound: " + secondBounds, firstBounds.equals(secondBounds)); + } + + @RobotKeyword("Checks if given two bounds are not equal. \n\n" + + "``firstBounds`` is an _Object:Bounds_ that specifies the first comparable Bounds\n\n" + + "``secondBounds`` is an _Object:Bounds_ that specifies the second comparable Bounds, see `3.2 Using objects`") + @ArgumentNames({ "firstBounds", "secondBounds" }) + 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" + + " First bound: " + firstBounds + "\n" + + " Second bound: " + secondBounds, !firstBounds.equals(secondBounds)); } @RobotKeyword("Fails if images are not similar enough\n\n" @@ -246,7 +404,7 @@ public void boundsShouldBeEqual(Bounds firstBounds, Bounds secondBounds) { + "This keyword can be coupled with e.g. `Capture Image` -keyword.") @ArgumentNames({ "image1", "image2", "percentage=100" }) public void imagesShouldMatch(Image image1, Image image2, double percentage) { - RobotLog.info("Checking if " + percentage + "% of " + image1 + " matches with " + image2); + RobotLog.info("Checking if " + percentage + "% of " + image1 + " matches with " + image2 + "."); if (image1.getHeight() != image2.getHeight() || image1.getWidth() != image2.getWidth()) throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() @@ -274,7 +432,7 @@ public void imagesShouldMatch(Image image1, Image image2) { + "This keyword can be coupled with e.g. `Capture Image` -keyword.") @ArgumentNames({ "image1", "image2", "percentage=100" }) public void imagesShouldNotMatch(Image image1, Image image2, double percentage) { - RobotLog.info("Checking if " + percentage + "% of " + image1 + " differs with " + image2); + RobotLog.info("Checking if " + percentage + "% of " + image1 + " differs with " + image2 + "."); if (image1.getHeight() != image2.getHeight() || image1.getWidth() != image2.getWidth()) throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() @@ -301,6 +459,7 @@ public void imagesShouldNotMatch(Image image1, Image image2) { @ArgumentNames({ "locator" }) public static void radioButtonShouldBeSelected(Object locator) { try { + RobotLog.info("Checking that radio button is selected: \"" + locator + "\"."); verifyThat((RadioButton) objectToNode(locator), ToggleMatchers.isSelected()); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as RadioButton!"); @@ -313,6 +472,7 @@ public static void radioButtonShouldBeSelected(Object locator) { @ArgumentNames({ "locator" }) public static void radioButtonShouldNotBeSelected(Object locator) { try { + RobotLog.info("Checking that radio button is not selected: \"" + locator + "\"."); verifyThat((RadioButton) objectToNode(locator), ToggleMatchers.isNotSelected()); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as RadioButton!"); @@ -325,6 +485,7 @@ public static void radioButtonShouldNotBeSelected(Object locator) { @ArgumentNames({ "locator" }) public static void toggleButtonShouldBeSelected(Object locator) { try { + RobotLog.info("Checking that toggle button is selected: \"" + locator + "\"."); verifyThat((ToggleButton) objectToNode(locator), ToggleMatchers.isSelected()); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as ToggleButton!"); @@ -337,6 +498,7 @@ public static void toggleButtonShouldBeSelected(Object locator) { @ArgumentNames({ "locator" }) public static void toggleButtonShouldNotBeSelected(Object locator) { try{ + RobotLog.info("Checking that toggle button is not selected: \"" + locator + "\"."); verifyThat((ToggleButton) objectToNode(locator), ToggleMatchers.isNotSelected()); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle given locator as ToggleButton!"); @@ -349,6 +511,7 @@ public static void toggleButtonShouldNotBeSelected(Object locator) { @ArgumentNames({ "locator", "timeout=20" }) public static void waitUntilProgressBarIsFinished(Object locator, int timeout) { try { + RobotLog.info("Waiting until progressbar is finished: \"" + locator + "\", timeout=\"" + timeout + "\"."); ProgressBar pb = (ProgressBar) objectToNode(locator); waitForProgressBarToFinish(pb, timeout); } catch (ClassCastException cce) { diff --git a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java index eb31498..e9596f6 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java @@ -170,6 +170,7 @@ public FxRobotInterface closeCurrentWindow() { + "| Write | Robot Framework | \n") @ArgumentNames({ "text" }) public FxRobotInterface write(String text) { + RobotLog.info("Writing \"" + text + "\" with keyboard."); try { return robot.write(text, sleepMillis); } catch (Exception e) { @@ -187,7 +188,8 @@ public void writeFast(String text) { RobotLog.info("Fast write not working in headless mode. Writing text normally"); this.write(text); } else { - try { + RobotLog.info("Writing \"" + text + "\" via clipboard."); + try { Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection testData = new StringSelection(text); c.setContents(testData, testData); @@ -212,8 +214,7 @@ public void writeFast(String text) { + "| Write To | .css-name | Robot Framework | \n") @ArgumentNames({ "locator", "text" }) public FxRobotInterface writeTo(Object locator, String text) { - RobotLog.info("Writing to " + locator); - + RobotLog.info("Writing \"" + text + "\" to " + locator); try { clickRobot.clickOn(locator); return robot.write(text, sleepMillis); diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index 5aa0ac0..50d75e2 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -106,6 +106,26 @@ public static Node waitUntilExists(String target, int timeout, String timeUnit) } } + public static void waitUntilDoesNotExists(String target, int timeout, String timeUnit) { + RobotLog.trace("Waiting until target \"" + target + "\" becomes non existent, timeout=" + + timeout + ", timeUnit=" + timeUnit); + + try { + waitFor(timeout, getTimeUnit(timeUnit), () -> { + return asyncFx(() -> createFinder().find(target) == null).get(); + }); + waitForFxEvents(); + } catch (JavaFXLibraryNonFatalException nfe) { + throw nfe; + } catch (TimeoutException te) { + throw new JavaFXLibraryTimeoutException("Given element \"" + target + "\" was still found within given timeout of " + + timeout + " " + timeUnit); + } catch (Exception e) { + RobotLog.trace("Exception in waitUntilDoesNotExists: " + e + "\n" + e.getCause().toString()); + throw new JavaFXLibraryNonFatalException("waitUntilDoesNotExist failed: ", e); + } + } + // TODO: Take same parameters as waitUntilExists in all waitUntil methods public static Node waitUntilVisible(Object target, int timeout) { @@ -123,12 +143,34 @@ public static Node waitUntilVisible(Object target, int timeout) { throw nfe; } catch (TimeoutException te) { throw new JavaFXLibraryTimeoutException("Given target \"" + target + "\" did not become visible within given timeout of " - + timeout + " seconds."); + + timeout + " " + TimeUnit.SECONDS); } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Something went wrong while waiting target to be visible: " + e.getMessage()); } } + public static Node waitUntilInvisible(Object target, int timeout) { + + // if target is a query string, let's try to find the relevant node + if (target instanceof String) + target = waitUntilExists((String) target, timeout, "SECONDS"); + + final Object finalTarget = target; + RobotLog.trace("Waiting until target \"" + target + "\" becomes invisible, timeout=" + timeout); + + try { + waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isInvisible()).matches(finalTarget)); + return (Node) target; + } catch (JavaFXLibraryNonFatalException nfe) { + throw nfe; + } catch (TimeoutException te) { + throw new JavaFXLibraryTimeoutException("Given target \"" + target + "\" did not become invisible within given timeout of " + + timeout + " " + TimeUnit.SECONDS); + } catch (Exception e) { + throw new JavaFXLibraryNonFatalException("Something went wrong while waiting target to be invisible: " + e.getMessage()); + } + } + public static Node waitUntilEnabled(Object target, int timeout) { if (target instanceof String) @@ -150,6 +192,27 @@ public static Node waitUntilEnabled(Object target, int timeout) { } } + public static Node waitUntilDisabled(Object target, int timeout) { + + if (target instanceof String) + target = waitUntilExists((String) target, timeout, "SECONDS"); + + final Object finalTarget = target; + RobotLog.trace("Waiting until target \"" + target + "\" becomes disabled, timeout=" + timeout); + + try { + waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isDisabled()).matches(finalTarget)); + return (Node) target; + } catch (JavaFXLibraryNonFatalException nfe) { + throw nfe; + } catch (TimeoutException te) { + throw new JavaFXLibraryTimeoutException("Given target \"" + target + "\" did not become disabled within given timeout of " + + timeout + " seconds."); + } catch (Exception e) { + throw new JavaFXLibraryNonFatalException("Something went wrong while waiting target to be disabled: " + e.getMessage()); + } + } + public static void waitForProgressBarToFinish(ProgressBar pb, int timeout) { try { waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(ProgressBarMatchers.isComplete()).matches(pb)); @@ -527,8 +590,8 @@ public static Class parseClass(String className) { } } } - - public static String loadRobotLibraryVersion() { + // TODO: Find way to use ROBOT_LIBRARY_VERSION directly from main class + public static String getVersion() { try { MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader("pom.xml")); diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDisabledTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDisabledTest.java new file mode 100644 index 0000000..ae8962f --- /dev/null +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDisabledTest.java @@ -0,0 +1,68 @@ +package javafxlibrary.utils.HelperFunctionsTests; + +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafxlibrary.TestFxAdapterTest; +import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; +import javafxlibrary.utils.HelperFunctions; +import mockit.Mock; +import mockit.MockUp; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class WaitUntilDisabledTest extends TestFxAdapterTest { + + private Button button; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setup() { + button = new Button("JavaFXLibrary"); + new MockUp() { + @Mock + Node waitUntilExists(String target, int timeout, String timeUnit) { + return button; + } + }; + } + + @Test + public void waitUntilDisabled_IsNotEnabled() { + button.setDisable(true); + Node node = HelperFunctions.waitUntilDisabled(".button", 1); + Assert.assertEquals(button, node); + } + + @Test + public void waitUntilDisabled_IsNotEnabledWithDelay() { + button.setDisable(false); + Thread t = disableButtonAfterTimeout(); + t.start(); + Node node = HelperFunctions.waitUntilDisabled(".button", 1); + Assert.assertEquals(button, node); + } + + @Test + public void waitUntilDisabled_IsEnabled() { + button.setDisable(false); + thrown.expect(JavaFXLibraryTimeoutException.class); + thrown.expectMessage("Given target \"" + button + "\" did not become disabled within given timeout of 1 seconds."); + HelperFunctions.waitUntilDisabled(".button", 1); + } + + private Thread disableButtonAfterTimeout() { + return new Thread(() -> { + try { + Thread.sleep(200); + button.setDisable(true); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + } +} diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDoesNotExistsTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDoesNotExistsTest.java new file mode 100644 index 0000000..15aaf8c --- /dev/null +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilDoesNotExistsTest.java @@ -0,0 +1,81 @@ +package javafxlibrary.utils.HelperFunctionsTests; + +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafxlibrary.TestFxAdapterTest; +import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; +import javafxlibrary.utils.HelperFunctions; +import javafxlibrary.utils.finder.Finder; +import mockit.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import testutils.DelayedObject; +import testutils.DelayedObjectRemoval; + +public class WaitUntilDoesNotExistsTest extends TestFxAdapterTest { + + @Mocked private Finder finder; + private Button button; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setup() { + button = new Button("JavaFXLibrary"); + new MockUp() { + @Mock + Finder createFinder() { + return finder; + } + }; + } + + @Test + public void waitUntilDoesNotExists_DoesNotExist() { + new Expectations() { + { + finder.find(".button"); result = null; + } + }; + + HelperFunctions.waitUntilDoesNotExists(".button", 500, "MILLISECONDS"); + } + + @Test + public void waitUntilDoesNotExists_DoesNotExistsWithDelay() { + DelayedObjectRemoval delayedObject = new DelayedObjectRemoval(button, 500); + + new Expectations() { + { + finder.find(".button"); + result = new Delegate() { + public Node delegate() throws Exception { + return (Node) delayedObject.getValue(); + } + }; + } + }; + + delayedObject.start(); + HelperFunctions.waitUntilDoesNotExists(".button", 1000, "MILLISECONDS"); + + } + + @Test + public void waitUntilDoesNotExists_Exist() { + + new Expectations() { + { + finder.find(".button"); result = button; + } + }; + + thrown.expect(JavaFXLibraryTimeoutException.class); + thrown.expectMessage("Given element \".button\" was still found within given timeout of 500 MILLISECONDS"); + HelperFunctions.waitUntilDoesNotExists(".button", 500, "MILLISECONDS"); + } +} diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilInvisibleTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilInvisibleTest.java new file mode 100644 index 0000000..8e98ef3 --- /dev/null +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilInvisibleTest.java @@ -0,0 +1,70 @@ +package javafxlibrary.utils.HelperFunctionsTests; + +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafxlibrary.TestFxAdapterTest; +import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; +import javafxlibrary.utils.HelperFunctions; +import mockit.Mock; +import mockit.MockUp; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class WaitUntilInvisibleTest extends TestFxAdapterTest { + + private Button button; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setup() { + button = new Button("JavaFXLibrary"); + new MockUp() { + @Mock + Node waitUntilExists(String target, int timeout, String timeUnit) { + return button; + } + }; + } + + @Test + public void waitUntilInvisible_IsInvisible() { + button.setVisible(false); + Node node = HelperFunctions.waitUntilInvisible(".button", 1); + Assert.assertEquals(button, node); + } + + @Test + public void waitUntilInvisible_IsInvisibleWithDelay() { + + button.setVisible(true); + + Thread t = setInvisibleAfterTimeout(); + t.start(); + Node node = HelperFunctions.waitUntilInvisible(".button", 1); + Assert.assertEquals(button, node); + } + + @Test + public void waitUntilInvisible_IsVisible() { + button.setVisible(true); + thrown.expect(JavaFXLibraryTimeoutException.class); + thrown.expectMessage("Given target \"" + button + "\" did not become invisible within given timeout of 1 SECONDS"); + HelperFunctions.waitUntilInvisible(".button", 1); + } + + private Thread setInvisibleAfterTimeout() { + return new Thread(() -> { + try { + Thread.sleep(200); + button.setVisible(false); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + } +} diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilVisibleTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilVisibleTest.java index 02ba8ce..3c98475 100644 --- a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilVisibleTest.java +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilVisibleTest.java @@ -49,7 +49,7 @@ public void waitUntilVisible_IsVisibleWithDelay() { public void waitUntilVisible_IsNotVisible() { button.setVisible(false); thrown.expect(JavaFXLibraryTimeoutException.class); - thrown.expectMessage("Given target \"" + button + "\" did not become visible within given timeout of 1 seconds."); + thrown.expectMessage("Given target \"" + button + "\" did not become visible within given timeout of 1 SECONDS"); HelperFunctions.waitUntilVisible(".button", 1); } diff --git a/src/test/java/testutils/DelayedObjectRemoval.java b/src/test/java/testutils/DelayedObjectRemoval.java new file mode 100644 index 0000000..48ad57f --- /dev/null +++ b/src/test/java/testutils/DelayedObjectRemoval.java @@ -0,0 +1,33 @@ +package testutils; + +public class DelayedObjectRemoval { + + private Object object; + private int timeout; + private boolean finished; + + public DelayedObjectRemoval(Object object, int milliseconds) { + this.object = object; + this.timeout = milliseconds; + this.finished = false; + } + + public void start() { + Thread t = new Thread(() -> { + try { + Thread.sleep(this.timeout); + this.finished = true; + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + t.start(); + } + + // Returns object if timeout has not finished / null if timeout has finished + public Object getValue() { + if (this.finished) + return null; + return this.object; + } +} diff --git a/src/test/robotframework/acceptance/BoundsLocationTest.robot b/src/test/robotframework/acceptance/BoundsLocationTest.robot index 9a5364b..9c82cc5 100644 --- a/src/test/robotframework/acceptance/BoundsLocationTest.robot +++ b/src/test/robotframework/acceptance/BoundsLocationTest.robot @@ -76,7 +76,13 @@ Get Bounds Using XPath Query ${TARGET_Y} Evaluate ${Y_OFFSET} + ${T_DECORATION_HEIGHT} + ${300} ${TARGET_X} Evaluate ${X_OFFSET} + ${L_DECORATION_WIDTH} ${TARGET} Create Bounds ${TARGET_X} ${TARGET_Y} 600 300 - Bounds Should Be Equal ${BOUNDS} ${TARGET} + Bounds Should Be Equal ${BOUNDS} ${TARGET} + +Compare Different Size Bounds + [Tags] smoke + ${BOUNDS_BLUE} Get Bounds id=blue + ${BOUNDS_GREEN} Get Bounds id=green + Bounds Should Not Be Equal ${BOUNDS_BLUE} ${BOUNDS_GREEN} Get Bounds Of Id That Does Not Exist [Tags] smoke negative diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index dfcede7..68fc1b8 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -15,219 +15,219 @@ ${FINDER_APP} javafxlibrary.testapps.FinderApp *** Test Cases *** Find With TestFX Query - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${rectangle} Find \#green - ${text} Find .whiteText - Should Contain ${rectangle} Rectangle[id=green, x=300.0, y=0.0, width=150.0, height=150.0, fill=0x00a000ff] - Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${rectangle} Find \#green + ${text} Find .whiteText + Should Contain ${rectangle} Rectangle[id=green, x=300.0, y=0.0, width=150.0, height=150.0, fill=0x00a000ff] + Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE Find With XPath - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${rect_by_id} Find xpath=//Rectangle[@id="lime"] - ${rect_by_fill} Find xpath=//Rectangle[@fill="0xff1493ff"] - ${text} Find xpath=//Text[@text="75x75"] - Should Contain ${rect_by_id} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] - Should Contain ${rect_by_fill} Rectangle[id=pink, x=450.0, y=75.0, width=75.0, height=75.0, fill=0xff1493ff] - Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${rect_by_id} Find xpath=//Rectangle[@id="lime"] + ${rect_by_fill} Find xpath=//Rectangle[@fill="0xff1493ff"] + ${text} Find xpath=//Text[@text="75x75"] + Should Contain ${rect_by_id} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] + Should Contain ${rect_by_fill} Rectangle[id=pink, x=450.0, y=75.0, width=75.0, height=75.0, fill=0xff1493ff] + Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE Find With Class - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${rectangle} Find class=javafx.scene.shape.Rectangle - ${text} Find class=javafx.scene.text.Text - Should Contain ${rectangle} Rectangle[id=red, x=0.0, y=0.0, width=300.0, height=300.0, fill=0xff0000ff] - Should Contain ${text} Text[text="300x300", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${rectangle} Find class=javafx.scene.shape.Rectangle + ${text} Find class=javafx.scene.text.Text + Should Contain ${rectangle} Rectangle[id=red, x=0.0, y=0.0, width=300.0, height=300.0, fill=0xff0000ff] + Should Contain ${text} Text[text="300x300", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE Find With CSS Query - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${rectangle} Find css=\#violet - ${text} Find css=VBox HBox StackPane Text.whiteText - Should Contain ${rectangle} Rectangle[id=violet, x=525.0, y=0.0, width=75.0, height=75.0, fill=0x9400d3ff] - Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${rectangle} Find css=\#violet + ${text} Find css=VBox HBox StackPane Text.whiteText + Should Contain ${rectangle} Rectangle[id=violet, x=525.0, y=0.0, width=75.0, height=75.0, fill=0x9400d3ff] + Should Contain ${text} Text[text="75x75", x=0.0, y=0.0, alignment=CENTER, origin=BASELINE Find With ID - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${rectangle} Find id=darkblue - Should Contain ${rectangle} Rectangle[id=darkblue, x=300.0, y=150.0, width=300.0, height=150.0, fill=0x00008bff] + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${rectangle} Find id=darkblue + Should Contain ${rectangle} Rectangle[id=darkblue, x=300.0, y=150.0, width=300.0, height=150.0, fill=0x00008bff] Find With Chained Selectors - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${lime} Find css=VBox HBox Pane id=lime - ${blue} Find css=VBox HBox Pane xpath=//Rectangle[@width="600.0"] - Should Contain ${lime} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] - Should Contain ${blue} Rectangle[id=blue, x=0.0, y=0.0, width=600.0, height=300.0, fill=0x00bfffff] + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${lime} Find css=VBox HBox Pane id=lime + ${blue} Find css=VBox HBox Pane xpath=//Rectangle[@width="600.0"] + Should Contain ${lime} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] + Should Contain ${blue} Rectangle[id=blue, x=0.0, y=0.0, width=600.0, height=300.0, fill=0x00bfffff] Find With Root - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${root} Find css=Pane - ${rectangle} Find id=lime true ${root} - Should Contain ${rectangle} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${root} Find css=Pane + ${rectangle} Find id=lime true ${root} + Should Contain ${rectangle} Rectangle[id=lime, x=500.0, y=200.0, width=75.0, height=75.0, fill=0x00ff00ff] Find All With TestFX Query - [Tags] smoke - Set Test App ${BOUNDS_APP} - @{nodes} Find All .whiteText - Length Should Be ${nodes} 3 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + @{nodes} Find All .whiteText + Length Should Be ${nodes} 3 Find All With XPath - [Tags] smoke - Set Test App ${BOUNDS_APP} - @{all_rectangles} Find All xpath=//Rectangle - @{text_nodes} Find All xpath=//Text[@text="75x75"] - Length Should Be ${all_rectangles} 9 - Length Should Be ${text_nodes} 6 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + @{all_rectangles} Find All xpath=//Rectangle + @{text_nodes} Find All xpath=//Text[@text="75x75"] + Length Should Be ${all_rectangles} 9 + Length Should Be ${text_nodes} 6 Find All With CSS query - [Tags] smoke - Set Test App ${BOUNDS_APP} - @{nodes1} Find All css=VBox HBox > StackPane Rectangle - @{nodes2} Find All css=Pane Rectangle - @{nodes3} Find All css=Pane > Rectangle - Length Should Be ${nodes1} 5 - Length Should Be ${nodes2} 3 - Length Should Be ${nodes3} 2 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + @{nodes1} Find All css=VBox HBox > StackPane Rectangle + @{nodes2} Find All css=Pane Rectangle + @{nodes3} Find All css=Pane > Rectangle + Length Should Be ${nodes1} 5 + Length Should Be ${nodes2} 3 + Length Should Be ${nodes3} 2 Find All With Class - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${nodes} Find All class=javafx.scene.shape.Rectangle - Length Should Be ${nodes} 10 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${nodes} Find All class=javafx.scene.shape.Rectangle + Length Should Be ${nodes} 10 Find All With Chained Selectors - [Tags] smoke - Set Test App ${BOUNDS_APP} - @{nodes1} Find All css=VBox HBox VBox xpath=//Rectangle - @{nodes2} Find All css=VBox HBox StackPane xpath=//Rectangle[@width="75.0"] - Length Should Be ${nodes1} 6 - Length Should Be ${nodes2} 4 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + @{nodes1} Find All css=VBox HBox VBox xpath=//Rectangle + @{nodes2} Find All css=VBox HBox StackPane xpath=//Rectangle[@width="75.0"] + Length Should Be ${nodes1} 6 + Length Should Be ${nodes2} 4 Find All With Root - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${xroot} Find css=VBox HBox VBox HBox - ${croot} Find css=Pane - @{xpath} Find All xpath=//Rectangle[@width="75.0"] false ${xroot} - @{css} Find All css=StackPane > Rectangle false ${croot} - Length Should Be ${xpath} 4 - Length Should Be ${css} 1 + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${xroot} Find css=VBox HBox VBox HBox + ${croot} Find css=Pane + @{xpath} Find All xpath=//Rectangle[@width="75.0"] false ${xroot} + @{css} Find All css=StackPane > Rectangle false ${croot} + Length Should Be ${xpath} 4 + Length Should Be ${css} 1 Find Nth Node With XPath - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${node1} Find xpath=/VBox/HBox/VBox/HBox/VBox/HBox/StackPane - ${node2} Find xpath=/VBox/HBox/VBox/HBox/VBox/HBox/StackPane[2] - ${child1} Find css=Rectangle true ${node1} - ${child2} Find css=Rectangle true ${node2} - Should Contain ${child1} Rectangle[id=yellow, x=450.0, y=0.0, width=75.0, height=75.0, fill=0xffff00ff] - Should Contain ${child2} Rectangle[id=violet, x=525.0, y=0.0, width=75.0, height=75.0, fill=0x9400d3ff] + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${node1} Find xpath=/VBox/HBox/VBox/HBox/VBox/HBox/StackPane + ${node2} Find xpath=/VBox/HBox/VBox/HBox/VBox/HBox/StackPane[2] + ${child1} Find css=Rectangle true ${node1} + ${child2} Find css=Rectangle true ${node2} + Should Contain ${child1} Rectangle[id=yellow, x=450.0, y=0.0, width=75.0, height=75.0, fill=0xffff00ff] + Should Contain ${child2} Rectangle[id=violet, x=525.0, y=0.0, width=75.0, height=75.0, fill=0x9400d3ff] Find With Pseudo Class - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${root} Find css=VBox HBox VBox HBox StackPane - ${target} Find xpath=//Text[@text="150x150"] - Move To ${target} - ${result} Find pseudo=hover false ${root} - Should Be Equal ${result} ${target} + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${root} Find css=VBox HBox VBox HBox StackPane + ${target} Find xpath=//Text[@text="150x150"] + Move To ${target} + ${result} Find pseudo=hover false ${root} + Should Be Equal ${result} ${target} Find All With Pseudo Class - [Tags] smoke - Set Test App ${BOUNDS_APP} - ${node} Find xpath=//Text[@text="300x300"] - Move To ${node} - @{hovered} Find All pseudo=hover + [Tags] smoke + Set Test Application ${BOUNDS_APP} + ${node} Find xpath=//Text[@text="300x300"] + Move To ${node} + @{hovered} Find All pseudo=hover # Nodes behind have the hover pseudostate too, Find All returns all of these except the one used as a root in lookup - Length Should Be ${hovered} 3 - Should Contain ${hovered} ${node} + Length Should Be ${hovered} 3 + Should Contain ${hovered} ${node} Find Text Node With Text [Tags] smoke - Set Test App ${BOUNDS_APP} + Set Test Application ${BOUNDS_APP} ${result} Find text="300x150" Parents Should Be Equal ${result} id=darkblue Find All Text Nodes With Text - [Tags] smoke - Set Test App ${BOUNDS_APP} - @{result} Find All text="75x75" - Length Should Be ${result} 6 - Get Length ${result} + [Tags] smoke + Set Test Application ${BOUNDS_APP} + @{result} Find All text="75x75" + Length Should Be ${result} 6 + Get Length ${result} Nothing Is Found - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${node} Find css=NoSuchSelector - Should Be Empty ${node} + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${node} Find css=NoSuchSelector + Should Be Empty ${node} Nothing Is Found When failIfNotFound Is True - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${msg} Run Keyword And Expect Error * Find css=NoSuchSelector true - Should Be Equal ${msg} Unable to find anything with query: "css=NoSuchSelector" + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${msg} Run Keyword And Expect Error * Find css=NoSuchSelector true + Should Be Equal ${msg} Unable to find anything with query: "css=NoSuchSelector" Nothing Is Found With Find All - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${nodes} Find All css=NoSuchSelector - Should Be Empty ${nodes} + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${nodes} Find All css=NoSuchSelector + Should Be Empty ${nodes} Nothing Is Found With Find All When failIfNotFound Is True - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${msg} Run Keyword And Expect Error * Find All css=NoSuchSelector true - Should Be Equal ${msg} Unable to find anything with query: "css=NoSuchSelector" + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${msg} Run Keyword And Expect Error * Find All css=NoSuchSelector true + Should Be Equal ${msg} Unable to find anything with query: "css=NoSuchSelector" Previous Query Returns Nothing In Chained Selector - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${node} Find css=VBox css=ZBox Pane id=lime - Should Be Empty ${node} + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${node} Find css=VBox css=ZBox Pane id=lime + Should Be Empty ${node} Previous Query Returns Nothing In Chained Selector With Find All - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${nodes} Find All css=VBox css=ZBox Pane id=lime - Should Be Empty ${nodes} + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${nodes} Find All css=VBox css=ZBox Pane id=lime + Should Be Empty ${nodes} Previous Query Returns Nothing In Chained Selector When failIfNotFound Is True - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${msg} Run Keyword And Expect Error * Find css=VBox css=ZBox Pane id=lime true - Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime" + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${msg} Run Keyword And Expect Error * Find css=VBox css=ZBox Pane id=lime true + Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime" Previous Query Returns Nothing In Chained Selector With Find All When failIfNotFound Is True - [Tags] smoke negative - Set Test App ${BOUNDS_APP} - ${msg} Run Keyword And Expect Error * Find All css=VBox css=ZBox Pane id=lime true - Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime" + [Tags] smoke negative + Set Test Application ${BOUNDS_APP} + ${msg} Run Keyword And Expect Error * Find All css=VBox css=ZBox Pane id=lime true + Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime" Find Labeled Node With Text - [Tags] smoke - Set Test App javafxlibrary.testapps.TestWindowManagement - ${target} Find id=navigationDialog - ${result} Find text="Dialog Example" - Should Be Equal ${result} ${target} + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + ${target} Find id=navigationDialog + ${result} Find text="Dialog Example" + Should Be Equal ${result} ${target} Find All Labeled Nodes With Text - [Tags] smoke - Set Test App javafxlibrary.testapps.TestWindowManagement + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement Open Dialog In Window Management App - Write To id=nameField labeled text - Write To id=phoneField labeled text - Click On text="Add" - ${result} Find All text="labeled text" + Write To id=nameField labeled text + Write To id=phoneField labeled text + Click On text="Add" + ${result} Find All text="labeled text" # Lookup returns textareas and their text as separate nodes - Length Should Be ${result} 4 + Length Should Be ${result} 4 Find TextInputControl Node With Text - [Tags] smoke - Set Test App javafxlibrary.testapps.TestWindowManagement + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement Open Dialog In Window Management App Write To id=nameField Text input ${result} Find text="Text input" @@ -236,8 +236,8 @@ Find TextInputControl Node With Text Should Be Equal ${result} ${target} Find All TextInputControl Nodes With Text - [Tags] smoke - Set Test App javafxlibrary.testapps.TestWindowManagement + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement Open Dialog In Window Management App Write To id=nameField Finder test Write To id=phoneField Finder test @@ -247,91 +247,80 @@ Find All TextInputControl Nodes With Text Length Should Be ${result} 4 Find From Another Window - [Tags] smoke - Set Test App ${WINDOW_APP} - ${node} Find id=thirdWindowLabel - Should End With ${node} Label[id=thirdWindowLabel, styleClass=label]'Third window' + [Tags] smoke + Set Test Application ${WINDOW_APP} + ${node} Find id=thirdWindowLabel + Should End With ${node} Label[id=thirdWindowLabel, styleClass=label]'Third window' Find From Another Window Using Chained Selector - [Tags] smoke - Set Test App ${WINDOW_APP} - ${node} Find css=HBox id=thirdWindowLabel - Should End With ${node} Label[id=thirdWindowLabel, styleClass=label]'Third window' + [Tags] smoke + Set Test Application ${WINDOW_APP} + ${node} Find css=HBox id=thirdWindowLabel + Should End With ${node} Label[id=thirdWindowLabel, styleClass=label]'Third window' Find All From Multiple Windows - [Tags] smoke - Set Test App ${WINDOW_APP} - ${nodes} Find All css=.label - Length Should Be ${nodes} 3 + [Tags] smoke + Set Test Application ${WINDOW_APP} + ${nodes} Find All css=.label + Length Should Be ${nodes} 3 Find All From Multiple Windows Using Chained Selector - [Tags] smoke - Set Test App ${WINDOW_APP} - ${nodes} Find All css=HBox css=.label - Length Should Be ${nodes} 3 + [Tags] smoke + Set Test Application ${WINDOW_APP} + ${nodes} Find All css=HBox css=.label + Length Should Be ${nodes} 3 Find All From Multiple Windows Containing Multiple Matches Using Chained Selector - [Tags] smoke - Set Test App ${FINDER_APP} - ${nodes} Find All css=VBox css=HBox css=.button - Length Should Be ${nodes} 24 + [Tags] smoke + Set Test Application ${FINDER_APP} + ${nodes} Find All css=VBox css=HBox css=.button + Length Should Be ${nodes} 24 Find With Index - [Tags] smoke - Set Test App ${FINDER_APP} - ${root} Get Node Parent id=firstButton - ${target} Find xpath=/HBox/Button[4] true ${root} - ${button} Find css=Button[4] - Should Be Equal ${button} ${target} + [Tags] smoke + Set Test Application ${FINDER_APP} + ${root} Get Node Parent id=firstButton + ${target} Find xpath=/HBox/Button[4] true ${root} + ${button} Find css=Button[4] + Should Be Equal ${button} ${target} Find With Index - Chained Selector - [Tags] smoke - Set Test App ${FINDER_APP} - ${button} Find id=firstButton - Click On ${button} - ${node} Find css=VBox pseudo=hover[2] - Should Be Equal ${node} ${button} + [Tags] smoke + Set Test Application ${FINDER_APP} + ${button} Find id=firstButton + Click On ${button} + ${node} Find css=VBox pseudo=hover[2] + Should Be Equal ${node} ${button} Find With Index - Chained Selector Contains Index - [Tags] smoke - Set Test App ${FINDER_APP} - ${node} Find css=VBox[2] css=HBox Button - ${root} Get Node Parent text="Scene type 1" - ${target} Find xpath=/VBox/VBox[2]/HBox/Button true ${root} - Should Be Equal ${node} ${target} + [Tags] smoke + Set Test Application ${FINDER_APP} + ${node} Find css=VBox[2] css=HBox Button + ${root} Get Node Parent text="Scene type 1" + ${target} Find xpath=/VBox/VBox[2]/HBox/Button true ${root} + Should Be Equal ${node} ${target} Find All With Index [Tags] smoke - Set Test App ${FINDER_APP} + Set Test Application ${FINDER_APP} ${nodes} Find All css=Button[2] Length Should Be ${nodes} 4 All Nodes Should Have Text ${nodes} 2 Find All With Index - Chained Selector Contains Index [Tags] smoke - Set Test App ${FINDER_APP} + Set Test Application ${FINDER_APP} ${nodes} Find All css=VBox[2] css=HBox Button[1] Length Should Be ${nodes} 3 All Nodes Should Have Text ${nodes} 5 Find With Index Below Minimum Value - [Tags] smoke negative - Set Test App ${FINDER_APP} - ${msg} Run Keyword And Expect Error * Find css=VBox[0] - Should Be Equal ${msg} Invalid query "css=VBox[0]": Minimum index value is 1! + [Tags] smoke negative + Set Test Application ${FINDER_APP} + ${msg} Run Keyword And Expect Error * Find css=VBox[0] + Should Be Equal ${msg} Invalid query "css=VBox[0]": Minimum index value is 1! *** Keywords *** -Set Test App - [Arguments] ${APPLICATION} - Run Keyword Unless '${CURRENT_APPLICATION}' == '${APPLICATION}' Change Current Application ${APPLICATION} - -Change Current Application - [Arguments] ${APPLICATION} - Run Keyword Unless '${CURRENT_APPLICATION}' == 'NOT SET' Close Javafx Application - Set Suite Variable ${CURRENT_APPLICATION} ${APPLICATION} - Launch Javafx Application ${APPLICATION} - Set Screenshot Directory ${OUTPUT_DIR}${/}report-images - Parents Should Be Equal [Arguments] ${node1} ${node2} ${parent1} Get Node Parent ${node1} @@ -351,6 +340,7 @@ Teardown all tests All Nodes Should Have Text [Arguments] ${nodes} ${text} - :FOR ${node} IN @{nodes} - \ ${value} Get Node Text ${node} - \ Should Be Equal ${value} ${text} + FOR ${node} IN @{nodes} + ${value} Get Node Text ${node} + Should Be Equal ${value} ${text} + END \ No newline at end of file diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 99f415a..c2b232d 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -1,12 +1,13 @@ *** Settings *** Documentation Tests for AdditionalKeywords -Resource ../resource.robot +Resource ../resource.robot Library Collections Library String Suite Setup Setup All Tests Suite Teardown Close Javafx Application Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging +Force Tags set-misc *** Variables *** ${CURRENT_APPLICATION} NOT SET @@ -94,29 +95,36 @@ Set Node Visibility (Call Method With Argument Types That Require Casting) Set Test Application javafxlibrary.testapps.TestBoundsLocation ${node} Find id=yellow Node Should Be Visible ${node} + Run Keyword And Expect Error * Node Should Not Be Visible ${node} Call Object Method In Fx Application Thread ${node} setVisible (boolean)false Wait For Events In Fx Application Thread Run Keyword And Expect Error * Node Should Be Visible ${node} + Node Should Not Be Visible ${node} #Reset visibility to true Call Object Method In Fx Application Thread ${node} setVisible (boolean)true Wait For Events In Fx Application Thread Node Should Be Visible ${node} -Wait For Events In Fx Application Thread +Check That Element Is Hoverable [Tags] smoke demo-set - Set Test Application javafxlibrary.testapps.TestBoundsLocation + Set Test Application javafxlibrary.testapps.TestClickRobot Set Timeout 3 - ${node} Find id=red - Call Object Method In Fx Application Thread ${node} changeFillAfterTwoSeconds - Wait For Events In Fx Application Thread - ${result} Find id=red - Should End With ${result} fill=0x7fffd4ff] - # Reset color - Call Object Method In Fx Application Thread ${node} resetFillToRed - Wait For Events In Fx Application Thread - ${result} Find id=red - Should End With ${result} fill=0xff0000ff] - Set Timeout 0 + ${target_node}= Find id=resetButton + Call Object Method In Fx Application Thread ${target_node} setVisible (boolean)false + Run Keyword And Expect Error * Node Should Be Hoverable ${target_node} + Call Object Method In Fx Application Thread ${target_node} setVisible (boolean)true + Node Should Be Hoverable id=resetButton + [Teardown] Set Timeout 0 + +Check That Element Is Not Hoverable + [Tags] smoke demo-set negative + Set Test Application javafxlibrary.testapps.TestClickRobot + Set Timeout 3 + ${target_node}= Find id=resetButton + Run Keyword And Expect Error * Node Should Not Be Hoverable ${target_node} + Call Object Method In Fx Application Thread ${target_node} setVisible (boolean)false + Node Should Not Be Hoverable id=resetButton + [Teardown] Set Timeout 0 Find From Node [Tags] smoke @@ -156,14 +164,72 @@ Get Node Text Of Incompatible Node ${MSG} Run Keyword And Expect Error * Get Node Text ${NODE} Should End With ${MSG} Node has no getText method +Wait Until Element Exists + [Tags] negative smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + Click On id=navigationAlert + Run Keyword And Expect Error Given element "css=.dialog-pane .button" was not found within given timeout of 2 SECONDS + ... Wait Until Element Exists css=.dialog-pane .button ${2} + Click On css=.button + Wait Until Element Exists css=.dialog-pane .button ${5} + Click On css=.dialog-pane .button + +Wait Until Element Does Not Exists + [Tags] negative smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + Click On id=navigationAlert + Wait Until Element Does Not Exists css=.dialog-pane .button ${5} + Click On css=.button + Wait Until Element Exists css=.dialog-pane .button ${5} + Run Keyword And Expect Error Given element "css=.dialog-pane .button" was still found within given timeout of 2 SECONDS + ... Wait Until Element Does Not Exists css=.dialog-pane .button ${2} + Click On css=.dialog-pane .button + Wait Until Node Is Visible [Tags] smoke Set Test Application javafxlibrary.testapps.TestWindowManagement Click On id=navigationAlert + Run Keyword And Expect Error Given element "css=.dialog-pane .button" was not found within given timeout of 2 SECONDS + ... Wait Until Node Is Visible css=.dialog-pane .button ${2} Click On css=.button Wait Until Node Is Visible css=.dialog-pane .button ${5} Click On css=.dialog-pane .button +Wait Until Node Is Not Visible + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + Click On id=navigationAlert + ${target_node}= Find css=.button + Call Object Method In Fx Application Thread ${target_node} setVisible (boolean)false + Wait Until Node Is Not Visible ${target_node} ${5} + Call Object Method In Fx Application Thread ${target_node} setVisible (boolean)true + Click On css=.button + Run Keyword And Expect Error REGEXP:Given target ".*" did not become invisible within given timeout of 2 SECONDS + ... Wait Until Node Is Not Visible css=.dialog-pane .button ${2} + Click On css=.dialog-pane .button + +Wait Until Node Is Enabled + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + Click On id=navigationAlert + ${target_node}= Find css=.button + Call Object Method In Fx Application Thread ${target_node} setDisable (boolean)true + ${msg}= Run Keyword And Expect Error REGEXP:Given target.*did not become enabled within given timeout of 2 seconds. + ... Wait Until Node Is Enabled css=.button ${2} + Call Object Method In Fx Application Thread ${target_node} setDisable (boolean)false + Wait Until Node Is Enabled css=.button ${5} + +Wait Until Node Is Not Enabled + [Tags] smoke + Set Test Application javafxlibrary.testapps.TestWindowManagement + Click On id=navigationAlert + ${target_node}= Find css=.button + ${msg}= Run Keyword And Expect Error REGEXP:Given target.*did not become disabled within given timeout of 2 seconds. + ... Wait Until Node Is Not Enabled css=.button ${2} + Call Object Method In Fx Application Thread ${target_node} setDisable (boolean)true + Wait Until Node Is Not Enabled css=.button ${5} + [Teardown] Call Object Method In Fx Application Thread ${target_node} setDisable (boolean)false + Find All With Pseudo Class [Tags] smoke Set Test Application javafxlibrary.testapps.TestClickRobot @@ -298,21 +364,10 @@ Get Scene (Window) Should Be Equal ${target} ${result} *** Keywords *** -Set Test Application - [Arguments] ${APPLICATION} - Run Keyword Unless '${CURRENT_APPLICATION}' == '${APPLICATION}' Change Current Application ${APPLICATION} - Setup All Tests Import JavaFXLibrary Set Timeout 0 -Change Current Application - [Arguments] ${APPLICATION} - Run Keyword Unless '${CURRENT_APPLICATION}' == 'NOT SET' Close Javafx Application - Set Suite Variable ${CURRENT_APPLICATION} ${APPLICATION} - Launch Javafx Application ${APPLICATION} - Set Screenshot Directory ${OUTPUT_DIR}${/}report-images - Get First Player ${TABLE} Find id=table ${PLAYER} Get Table Cell Value ${TABLE} 0 0 diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index 271a7f9..7efcb68 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -59,31 +59,38 @@ List Windows [Tags] smoke ${INDEX} Set Variable ${0} ${LIST_WINDOWS} List Windows - :FOR ${WINDOW} IN @{LIST_WINDOWS} - \ ${TARGET} Get Window ${INDEX} - \ Should Be Equal ${WINDOW} ${TARGET} msg=Window lists does not match (index ${INDEX})! - \ ${INDEX} Set Variable ${INDEX+1} + FOR ${WINDOW} IN @{LIST_WINDOWS} + ${TARGET} Get Window ${INDEX} + Should Be Equal ${WINDOW} ${TARGET} msg=Window lists does not match (index ${INDEX})! + ${INDEX} Set Variable ${INDEX+1} + END List Target Windows [Tags] smoke ${INDEX} Set Variable ${0} ${LIST_WINDOWS} List Target Windows - :FOR ${WINDOW} IN @{LIST_WINDOWS} - \ ${TARGET} Get Window ${INDEX} - \ Should Be Equal ${WINDOW} ${TARGET} msg=Window lists does not match (index ${INDEX})! - \ ${INDEX} Set Variable ${INDEX+1} + FOR ${WINDOW} IN @{LIST_WINDOWS} + ${TARGET} Get Window ${INDEX} + Should Be Equal ${WINDOW} ${TARGET} msg=Window lists does not match (index ${INDEX})! + ${INDEX} Set Variable ${INDEX+1} + END -# Keyword is located in ConvenienceKeywords Bring Stage To Front - [Tags] smoke - ${second_window} Get Window Second window - Bring Stage To Front ${SECOND_WINDOW} - ${target} Get Target Window - Should Be Equal ${second_window} ${target} - ${third_window} Get Window Third window - Bring Stage To Front ${third_window} - ${target} Get Target Window - Should Be Equal ${third_window} ${target} + [Tags] smoke + ${second_window} Get Window Second window + Bring Stage To Front ${second_window} + Window Should Be Visible ${second_window} + Click On ${second_window} + Window Should Be Focused ${second_window} + ${target} Get Target Window + Should Be Equal ${second_window} ${target} + ${third_window} Get Window Third window + Bring Stage To Front ${third_window} + ${target} Get Target Window + Should Be Equal ${third_window} ${target} + Window Should Not Be Focused ${second_window} + Call Object Method In Fx Application Thread ${second_window} hide + Window Should Not Be Visible ${second_window} # On Mac the testing application had to be modified to register CMD + W. # Close Current Window uses ALT + F4 on Windows, so it should work with no changes to the testing application. diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index fa82c95..76d4023 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -15,3 +15,19 @@ Disable Embedded Image Logging For Negative Tests Enable Image Logging Set Image Logging EMBEDDED + +Set Test Application + [Arguments] ${application} + Run Keyword Unless '${CURRENT_APPLICATION}' == '${application}' Change Current Application ${application} + +Change Current Application + [Arguments] ${application} + Run Keyword Unless '${CURRENT_APPLICATION}' == 'NOT SET' Close Javafx Application + Set Suite Variable ${CURRENT_APPLICATION} ${application} + Launch Javafx Application ${application} + Bring First Window To Front + Set Screenshot Directory ${OUTPUT_DIR}${/}report-images + +Bring First Window To Front + ${window_list}= List Windows + Set Target Window ${window_list}[0]