Skip to content

Queries

Benjamin Gudehus edited this page Mar 3, 2016 · 12 revisions

WikiDocumentationQueries

lookup()

Allows to query one or more Nodes.

Basic usage

The basic usage of lookup() is to pass a query object to it and to specify whether to return one or more Nodes.

lookup(query)                             // returns a node query.
lookup(query).query()                     // returns a node or null.
lookup(query).queryAll()                  // returns a set of nodes.
lookup(query).tryQuery()                  // returns an optional node.

It is possible to use a string as query object.

lookup("Cancel")                          // using the text of a labeled node.
lookup(".button")                         // using the CSS class of nodes.
lookup("#cancelButton")                   // using the CSS id of a node.
lookup(".tool-box #expander")             // using a whole CSS selector.

For more detailed queries an existing matcher or a custom predicate can be used.

lookup(hasText("Cancel"))                 // using a matcher.
lookup((Button b) -> b.isCancelButton())  // using a predicate.

Using other root Nodes

fromAll().lookup(query)                   // using the roots of all windows.
from(node).lookup(query)                  // using a single node as root.
from(node, otherNode).lookup(query)       // using multiple nodes as roots.
from(rootNode(node)).lookup(query)
from(rootNode(scene)).lookup(query)
from(rootNode(stage)).lookup(query)
lookup(query).match(matcher)
lookup(query).match(predicate)
from(listView).lookup(".list-cell").nth(3)

point()

Allows to query a Point2D.

point(target)                             // returns a `PointQuery`.
point("Submit")                           // using a text query.
point(".button")                          // using a CSS selector.
point(lookup(queryString))                // using a node query.
point(100, 200)                           // using screen coordinates.
point(new Point2D(100, 200))              // using a screen position.
point(new BoundingBox(0, 0, 200, 400))    // using a screen area.
point(point(100, 200))                    // using a screen position query.
point(bounds(0, 0, 200, 400))             // using a screen area query.
offset(point, 100, 200)

bounds()

window()

snapshot()

You can’t perform that action at this time.