Skip to content

Commit 0a29c42

Browse files
committed
Merge branches 'embedded-screenshots' and 'testfx-4.0.14'
2 parents b1b13a1 + a70be77 commit 0a29c42

File tree

6 files changed

+78
-15
lines changed

6 files changed

+78
-15
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@
315315
<dependency>
316316
<groupId>org.testfx</groupId>
317317
<artifactId>testfx-core</artifactId>
318-
<version>4.0.13-alpha</version>
318+
<version>4.0.14-alpha</version>
319319
</dependency>
320320
<dependency>
321321
<groupId>org.testfx</groupId>
322322
<artifactId>testfx-junit</artifactId>
323-
<version>4.0.13-alpha</version>
323+
<version>4.0.14-alpha</version>
324324
</dependency>
325325
<dependency>
326326
<groupId>org.testfx</groupId>

src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.robotframework.javalib.annotation.RobotKeywords;
2828
import org.testfx.api.FxRobot;
2929
import org.testfx.api.FxRobotInterface;
30-
import org.testfx.api.annotation.Unstable;
3130
import java.awt.*;
3231
import java.awt.datatransfer.Clipboard;
3332
import java.awt.datatransfer.StringSelection;
@@ -65,7 +64,6 @@ public FxRobotInterface press(String... keys) {
6564
+ "| Release | CONTROL | SHIFT | G | \n"
6665
+ "Note: passing in an empty list will release all pressed keys.\n\n")
6766
@ArgumentNames({ "*keys" })
68-
@Unstable(reason = "could be renamed to accept empty arrays")
6967
public FxRobotInterface release(String... keys) {
7068
try {
7169
RobotLog.info("Releasing keys: " + Arrays.asList(keys));
@@ -145,7 +143,6 @@ public FxRobotInterface eraseText(int amount) {
145143
}
146144

147145
@RobotKeyword("Closes the current window, same as ALT + F4 in Windows \n\n")
148-
@Unstable(reason = "maybe extract this into a new class")
149146
public FxRobotInterface closeCurrentWindow() {
150147
try {
151148
if (isMac()) {

src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.robotframework.javalib.annotation.RobotKeyword;
2626
import org.robotframework.javalib.annotation.RobotKeywords;
2727
import org.testfx.api.FxRobotInterface;
28-
import org.testfx.api.annotation.Unstable;
2928

3029
import java.util.Arrays;
3130

@@ -37,7 +36,6 @@ public class MouseRobot extends TestFxAdapter {
3736
+ "\nExample: \n"
3837
+ "| Press Mouse Button | PRIMARY | \n")
3938
@ArgumentNames({ "*buttons" })
40-
@Unstable(reason = "could be renamed to accept empty arrays")
4139
public FxRobotInterface pressMouseButton(String... buttons) {
4240

4341
try {
@@ -55,7 +53,6 @@ public FxRobotInterface pressMouseButton(String... buttons) {
5553
+ "\nExample: \n"
5654
+ "| Release Mouse Button | SECONDARY | \n")
5755
@ArgumentNames({ "*buttons" })
58-
@Unstable(reason = "could be renamed to accept empty arrays")
5956
public FxRobotInterface releaseMouseButton(String... buttons) {
6057
try {
6158
RobotLog.info("Releasing mouse buttons: \"" + Arrays.asList(buttons) + "\"");

src/main/java/javafxlibrary/utils/finder/FindOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import javafxlibrary.matchers.InstanceOfMatcher;
2626
import javafxlibrary.utils.TestFxAdapter;
2727
import org.testfx.api.FxRobotInterface;
28-
import org.testfx.matcher.control.LabeledMatchers;
2928
import org.testfx.service.query.NodeQuery;
29+
import org.testfx.util.NodeQueryUtils;
3030

3131
import java.util.*;
3232

@@ -77,7 +77,7 @@ private Object executeLookup(FindPrefix prefix, String lookupQuery) {
7777
NodeQuery classLookupResults = classLookup(root, lookupQuery);
7878
return findAll ? classLookupResults.queryAll() : classLookupResults.query();
7979
case TEXT:
80-
NodeQuery textLookupResults = robot.from(root).lookup(LabeledMatchers.hasText(lookupQuery));
80+
NodeQuery textLookupResults = robot.from(root).lookup(NodeQueryUtils.hasText(lookupQuery));
8181
return findAll ? textLookupResults.queryAll() : textLookupResults.query();
8282
case XPATH:
8383
XPathFinder xPathFinder = new XPathFinder();

src/main/java/javafxlibrary/utils/finder/Finder.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javafxlibrary.utils.RobotLog;
2424
import javafxlibrary.utils.TestFxAdapter;
2525
import org.testfx.api.FxRobotInterface;
26+
import org.testfx.service.query.EmptyNodeQueryException;
2627

2728
import java.util.*;
2829

@@ -141,13 +142,21 @@ private Set<Node> findAll(Parent root, int queryIndex) {
141142

142143
private Node executeFind(Parent root, Query query) {
143144
RobotLog.debug("Executing find with root: " + root + " and query: " + query.getQuery());
144-
FindOperation findOperation = new FindOperation(root, query, false);
145-
return (Node) findOperation.executeLookup();
145+
try {
146+
FindOperation findOperation = new FindOperation(root, query, false);
147+
return (Node) findOperation.executeLookup();
148+
} catch (EmptyNodeQueryException e) {
149+
return null;
150+
}
146151
}
147152

148153
private Set<Node> executeFindAll(Parent root, Query query) {
149154
RobotLog.debug("Executing find all with root: " + root + " and query: " + query.getQuery());
150-
FindOperation findOperation = new FindOperation(root, query, true);
151-
return new LinkedHashSet<>((Set<Node>)findOperation.executeLookup());
155+
try {
156+
FindOperation findOperation = new FindOperation(root, query, true);
157+
return new LinkedHashSet<>((Set<Node>)findOperation.executeLookup());
158+
} catch (EmptyNodeQueryException e) {
159+
return Collections.emptySet();
160+
}
152161
}
153162
}

src/test/robotframework/acceptance/FindTest.robot

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,18 @@ Find All With Pseudo Class
146146
Length Should Be ${hovered} 3
147147
Should Contain ${hovered} ${node}
148148

149-
# TODO: Add test for text= prefix when next TestFX version comes out (4.0.14-alpha)
149+
Find Text Node With Text
150+
[Tags] smoke
151+
Set Test App ${BOUNDS_APP}
152+
${result} Find text="300x150"
153+
Parents Should Be Equal ${result} id=darkblue
154+
155+
Find All Text Nodes With Text
156+
[Tags] smoke
157+
Set Test App ${BOUNDS_APP}
158+
@{result} Find All text="75x75"
159+
Length Should Be ${result} 6
160+
Get Length ${result}
150161

151162
Nothing Is Found
152163
[Tags] smoke negative
@@ -196,6 +207,45 @@ Previous Query Returns Nothing In Chained Selector With Find All When failIfNotF
196207
${msg} Run Keyword And Expect Error * Find All css=VBox css=ZBox Pane id=lime true
197208
Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime"
198209

210+
Find Labeled Node With Text
211+
[Tags] smoke
212+
Set Test App javafxlibrary.testapps.TestWindowManagement
213+
${target} Find id=navigationDialog
214+
${result} Find text="Dialog Example"
215+
Should Be Equal ${result} ${target}
216+
217+
Find All Labeled Nodes With Text
218+
[Tags] smoke
219+
Set Test App javafxlibrary.testapps.TestWindowManagement
220+
Open Dialog In Window Management App
221+
Write To id=nameField labeled text
222+
Write To id=phoneField labeled text
223+
Click On text="Add"
224+
${result} Find All text="labeled text"
225+
# Lookup returns textareas and their text as separate nodes
226+
Length Should Be ${result} 4
227+
228+
Find TextInputControl Node With Text
229+
[Tags] smoke
230+
Set Test App javafxlibrary.testapps.TestWindowManagement
231+
Open Dialog In Window Management App
232+
Write To id=nameField Text input
233+
${result} Find text="Text input"
234+
${target} Find id=nameField
235+
Click On text="Add"
236+
Should Be Equal ${result} ${target}
237+
238+
Find All TextInputControl Nodes With Text
239+
[Tags] smoke
240+
Set Test App javafxlibrary.testapps.TestWindowManagement
241+
Open Dialog In Window Management App
242+
Write To id=nameField Finder test
243+
Write To id=phoneField Finder test
244+
${result} Find All text="Finder test"
245+
Click On text="Add"
246+
# Lookup returns textareas and their text as separate nodes
247+
Length Should Be ${result} 4
248+
199249
Find From Another Window
200250
[Tags] smoke
201251
Set Test App ${WINDOW_APP}
@@ -282,6 +332,16 @@ Change Current Application
282332
Launch Javafx Application ${APPLICATION}
283333
Set Screenshot Directory ${OUTPUT_DIR}${/}report-images
284334

335+
Parents Should Be Equal
336+
[Arguments] ${node1} ${node2}
337+
${parent1} Get Node Parent ${node1}
338+
${parent2} Get Node Parent ${node2}
339+
Should Be Equal ${parent1} ${parent2}
340+
341+
Open Dialog In Window Management App
342+
Click On id=navigationDialog
343+
Click On id=addEmployeeButton
344+
285345
Setup All Tests
286346
Import JavaFXLibrary
287347
Set Timeout 0

0 commit comments

Comments
 (0)