54
54
@ RobotKeywords
55
55
public class ConvenienceKeywords extends TestFxAdapter {
56
56
57
- @ Deprecated
58
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n \n " +
59
- "finder that mimics _xpath_ style search.\n \n "
60
- + "``query`` is a query locator, see `3.1 Locator syntax`.\n \n "
61
- + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
62
- + "keyword returns null in case lookup returns nothing.\n \n "
63
- + "\n Example:\n "
64
- + " | ${node}= | Find With Path | .main-view[0] .split-pane[0] \\ #node-id class=GridPane .toggle-button[3] sometext | " )
65
- @ ArgumentNames ({"query" , "failIfNotFound=False" })
66
- public Object findWithPath (String query , boolean failIfNotFound ){
67
-
68
- try {
69
- return mapObject (findNode (query ));
70
-
71
- } catch (JavaFXLibraryNonFatalException e ){
72
- if (failIfNotFound )
73
- throw new JavaFXLibraryNonFatalException ("Unable to find anything with query: \" " + query + "\" " );
74
- return "" ;
75
-
76
- } catch (Exception e ) {
77
- throw new JavaFXLibraryNonFatalException ("Find operation failed for query: \" " + query + "\" " , e );
78
- }
79
- }
80
-
81
57
@ RobotKeyword ("Brings the given stage to front\n \n "
82
58
+ "``stage`` is an Object:Stage to be set in front of others, see `3.2 Using locators as keyword arguments`. \n \n " )
83
59
@ ArgumentNames ({ "stage" })
@@ -130,116 +106,6 @@ public void callObjectMethodInFxApplicationThread(Object object, String method,
130
106
callMethod (object , method , finalArgs , true );
131
107
}
132
108
133
- @ Deprecated
134
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n \n "
135
- + "Returns the *first* node matching the query. \n \n "
136
- + "``query`` is the Class name String to use in lookup.\n "
137
- + "\n Example:\n "
138
- + "| ${my node}= | Find | javafx.scene.control.Button | # button class |" )
139
- @ ArgumentNames ({ "query" })
140
- public Object findClass (final String query ) {
141
- try {
142
- Class <?> clazz = Class .forName (query );
143
- InstanceOfMatcher matcher = new InstanceOfMatcher (clazz );
144
- return mapObject (robot .lookup (matcher ).query ());
145
- } catch (Exception e ) {
146
- RobotLog .trace ("Problem has occurred during node lookup: " + e );
147
- return "" ;
148
- }
149
- }
150
-
151
- @ Deprecated
152
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n \n "
153
- + "Returns *all* descendant nodes of given node matching the query. \n \n "
154
- + "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using locators as keyword arguments`. \n \n "
155
- + "``query`` is a query locator, see `3.1 Locator syntax`.\n \n "
156
- + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
157
- + "keyword returns null in case lookup returns nothing.\n \n "
158
- + "\n Example:\n "
159
- + "| ${my nodes}= | Find All From Node | ${some node} | .css | \n "
160
- + "See keyword `Find` for further examples of query usage.\n " )
161
- @ ArgumentNames ({ "node" , "query" , "failIfNotFound=False" })
162
- public List <Object > findAllFromNode (Object node , String query , boolean failIfNotFound ) {
163
- try {
164
- if ( node instanceof Node ) {
165
- RobotLog .info ("Trying to find all nodes with query: \" " + query + "\" that are under starting " +
166
- "point node: \" " + node + "\" , failIfNotFound= \" " + failIfNotFound + "\" " );
167
- return mapObjects (((Node ) node ).lookupAll (query ));
168
- }
169
- // fail in case no valid node argument.
170
- failIfNotFound = true ;
171
- throw new JavaFXLibraryNonFatalException ("Illegal argument type for node." );
172
- } catch (JavaFXLibraryNonFatalException e ){
173
- if (failIfNotFound )
174
- throw e ;
175
- return Collections .emptyList ();
176
-
177
- } catch (Exception e ) {
178
- throw new JavaFXLibraryNonFatalException ("Find all from node operation failed for node: \" " + node .toString () +
179
- "\" and query: " + query , e );
180
- }
181
- }
182
-
183
- @ Deprecated
184
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n \n "
185
- + "Returns *all* nodes matching query AND given pseudo-class state. \r \n "
186
- + "``query`` is a query locator, see `3.1 Locator syntax`.\n \n "
187
- + "``pseudo`` is a String value specifying pseudo class value.\n \n "
188
- + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
189
- + "keyword returns null in case lookup returns nothing.\n \n "
190
- + "\n Example:\n "
191
- + "| ${my node}= | Find All With Pseudo Class | .check-box-tree-cell .check-box | selected | \n " )
192
- @ ArgumentNames ({ "query" , "pseudo" , "failIfNotFound=False" })
193
- public List <Object > findAllWithPseudoClass (String query , String pseudo , boolean failIfNotFound ) {
194
- RobotLog .info ("Trying to find all nodes with query: \" " + query + "\" that has pseudoclass state as: \" " +
195
- pseudo + "\" , failIfNotFound= \" " + failIfNotFound + "\" " );
196
- try {
197
- Set <Node > nodes = robot .lookup (query ).queryAll ();
198
- Set <Node > matches = nodes .stream ()
199
- .filter (n -> n .getPseudoClassStates ().stream ().
200
- map (PseudoClass ::getPseudoClassName ).anyMatch (pseudo ::contains ))
201
- .collect (Collectors .toSet ());
202
- return mapObjects (matches );
203
-
204
- } catch (JavaFXLibraryNonFatalException e ){
205
- if (failIfNotFound )
206
- throw e ;
207
- return Collections .emptyList ();
208
-
209
- } catch (Exception e ) {
210
- throw new JavaFXLibraryNonFatalException ("Find all with pseudo class operation failed for query: \" " +
211
- query + "\" and pseudo: \" " + pseudo + "\" " , e );
212
- }
213
- }
214
-
215
- @ Deprecated
216
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n \n "
217
- + "Returns the *first* descendant node of given node matching the query. \n \n "
218
- + "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using locators as keyword arguments`. \n \n "
219
- + "``query`` is a query locator, see `3.1 Locator syntax`.\n \n "
220
- + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
221
- + "keyword returns null in case lookup returns nothing.\n \n "
222
- + "\n Example:\n "
223
- + "| ${my node}= | Find From Node | ${some node} | .css |\n "
224
- + "See keyword `Find` for further examples of query usage.\n " )
225
- @ ArgumentNames ({ "node" , "query" , "failIfNotFound=False" })
226
- public Object findFromNode (Node node , String query , boolean failIfNotFound ) {
227
- RobotLog .info ("Trying to find: \" " + query + "\" from node: \" " + node + "\" , failIfNotFound= \" " + failIfNotFound + "\" " );
228
- try {
229
- Node childNode = node .lookup (query );
230
- return mapObject (childNode );
231
-
232
- } catch (JavaFXLibraryNonFatalException e ){
233
- if (failIfNotFound )
234
- throw e ;
235
- return "" ;
236
-
237
- } catch (Exception e ) {
238
- throw new JavaFXLibraryNonFatalException ("Find from node operation failed for node: \" " + node +
239
- "\" and query: " + query , e );
240
- }
241
- }
242
-
243
109
@ RobotKeyword ("Lists methods available for given node.\n "
244
110
+ "``node`` is the Object:Node which methods to list, see `3.2 Using locators as keyword arguments`. \n \n "
245
111
+ "When working with custom components you may use this keyword to discover methods you can call "
@@ -390,40 +256,6 @@ public Set<PseudoClass> getPseudoClassStates(Object locator) {
390
256
}
391
257
}
392
258
393
- // TODO: Should this be deleted? Find All From Node has the same functionality
394
- @ Deprecated
395
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n \n "
396
- + "Returns *all* descendant nodes of given node matching the given Java class name. \n \n "
397
- + "``locator`` is either a _query_ or _Object_ for node whose children will be queried, see "
398
- + "`3.2 Using locators as keyword arguments`. \n \n "
399
- + "``className`` is the Java class name to look for.\n "
400
- + "\n Example:\n "
401
- + "| ${panes}= | Get Node Children By Class Name | ${some node} | BorderPane | \n "
402
- + "Returns an empty list if none is found. \n " )
403
- @ ArgumentNames ({ "node" , "className" })
404
- public Set <Object > getNodeChildrenByClassName (Object locator , String className ) {
405
- Node node = objectToNode (locator );
406
- RobotLog .info ("Getting node: \" " + node + "\" children by class name: \" " + className + "\" " );
407
- try {
408
- Set <Object > keys = new HashSet <>();
409
- Set childNodes = node .lookupAll ("*" );
410
-
411
- for (Object o : childNodes ) {
412
- Node childNode = (Node ) o ;
413
- if (childNode .getClass ().getSimpleName ().equals (className )) {
414
- RobotLog .trace ("Classname: \" " + className + "\" found: \" " + childNode + "\" " );
415
- keys .add (mapObject (childNode ));
416
- }
417
- }
418
- return keys ;
419
- } catch (Exception e ) {
420
- if (e instanceof JavaFXLibraryNonFatalException )
421
- throw e ;
422
- throw new JavaFXLibraryNonFatalException ("Unable to get node children for node: \" " + node .toString () +
423
- "\" with class name: " + className , e );
424
- }
425
- }
426
-
427
259
@ RobotKeyword ("Returns text value of the Node. \n \n "
428
260
+ "``locator`` is either a _query_ or _Object_ for a node whose getText method will be called, see "
429
261
+ "`3. Locating JavaFX Nodes`. \n \n " )
@@ -441,35 +273,6 @@ public String getNodeText(Object locator) {
441
273
}
442
274
}
443
275
444
- @ Deprecated
445
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n \n "
446
- + "Returns height value of the node. \n \n "
447
- + "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
448
- + "`3. Locating JavaFX Nodes`. \n \n " )
449
- @ ArgumentNames ({ "locator" })
450
- public String getNodeHeight (Object locator ) {
451
- Node node = objectToNode (locator );
452
- try {
453
- Method [] methods = node .getClass ().getMethods ();
454
- for (Method m : methods ) {
455
- if (m .getName ().equals ("getHeight" )) {
456
- try {
457
- Object result = m .invoke (node , (Object ) null );
458
- return result .toString ();
459
- } catch (Exception e ) {
460
- throw new JavaFXLibraryNonFatalException ("Problem calling method: .getHeight(): " + e .getMessage (), e );
461
- }
462
- }
463
- }
464
- throw new JavaFXLibraryNonFatalException (
465
- "Get node height failed for node: \" " + node .toString () + "\" . Element has no method getHeight()" );
466
- } catch (Exception e ) {
467
- if (e instanceof JavaFXLibraryNonFatalException )
468
- throw e ;
469
- throw new JavaFXLibraryNonFatalException ("Unable to get node height for node: " + node .toString (), e );
470
- }
471
- }
472
-
473
276
@ RobotKeyword ("Returns image name and path of the node. \n \n "
474
277
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
475
278
+ "`3. Locating JavaFX Nodes`. \n \n "
@@ -535,31 +338,6 @@ public String getObjectClassName(Object locator) {
535
338
}
536
339
}
537
340
538
- @ Deprecated
539
- @ RobotKeyword ("*DEPRECATED in version 0.6.0!* Use keyword `Get Scene` instead.\n \n "
540
- +"Returns given locators Scene object. \n \n "
541
- + "``locator`` is either a _query_ or a _Node_, see `3.2 Using locators as keyword arguments`\n \n " )
542
- @ ArgumentNames ({ "locator" })
543
- public Object getNodesScene (Object locator ) {
544
- try {
545
- if (locator instanceof Node ){
546
- RobotLog .info ("Getting a Scene object for a Node: \" " + locator + "\" " );
547
- return mapObject (((Node ) locator ).getScene ());
548
- } else if (locator instanceof String ) {
549
- RobotLog .info ("Getting a Scene object for a query: \" " + locator + "\" " );
550
- Node node = objectToNode (locator );
551
- return mapObject (node .getScene ());
552
- }
553
-
554
- throw new JavaFXLibraryNonFatalException ("Locator type is not a Node or a query string!" );
555
-
556
- } catch (Exception e ) {
557
- if (e instanceof JavaFXLibraryNonFatalException )
558
- throw e ;
559
- throw new JavaFXLibraryNonFatalException ("Unable to get Scene object for locator: \" " + locator + "\" " , e );
560
- }
561
- }
562
-
563
341
@ RobotKeyword ("Returns Scene of the given object. \n \n "
564
342
+ "``locator`` is either a _query_, a _Node_ or a _Window_, see `3.2 Using locators as keyword arguments`\n \n " )
565
343
@ ArgumentNames ({ "locator" })
0 commit comments