Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a70be77

Browse files
committed
Enable finding non labeled text nodes
1 parent 3db7eb9 commit a70be77

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

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

+2-2
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/test/robotframework/acceptance/FindTest.robot

+61-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,18 @@ Find All With Pseudo Class
144144
Length Should Be ${hovered} 3
145145
Should Contain ${hovered} ${node}
146146

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

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

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

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

0 commit comments

Comments
 (0)