diff --git a/articles/flow/testing/browserless/component-query.adoc b/articles/flow/testing/browserless/component-query.adoc index 07f28708f2..137d312abc 100644 --- a/articles/flow/testing/browserless/component-query.adoc +++ b/articles/flow/testing/browserless/component-query.adoc @@ -16,28 +16,31 @@ To overcome this limitation, [classname]`BrowserlessTest` provides a component q == Component Queries -You can get a [classname]`ComponentQuery` object by calling the [methodname]`$()` method, specifying the type of the component you are searching for. +You can get a [classname]`ComponentQuery` object by calling the [methodname]`find()` method, specifying the type of the component you are searching for. Once the query is ready with all conditions configured, use a terminal operator to retrieve the components that it found. Examples of terminal operators are [methodname]`single()`, [methodname]`last()`, [methodname]`atIndex()`, [methodname]`all()`, and [methodname]`id()`. [source,java] ---- // Get the TextField -TextField nameField = $(TextField.class).single(); +TextField nameField = find(TextField.class).single(); ---- +[NOTE] +[classname]`BrowserlessTest` retains [methodname]`$()` and [methodname]`$view()` as deprecated aliases for [methodname]`find()` and [methodname]`findInView()`, scheduled for removal in 2.0. The newer composition-based APIs ([classname]`BrowserlessExtension`, [classname]`BrowserlessClassExtension`, and [classname]`BrowserlessUIContext`) only expose [methodname]`find()` and [methodname]`findInView()`. + === Scoping Queries -You can also restrict search scope to the children of the current view by using the [methodname]`$view()` method, or even to another component by using [methodname]`$(MyComponent.class, rootComponent)`. +You can also restrict search scope to the children of the current view by using the [methodname]`findInView()` method, or even to another component by using [methodname]`find(MyComponent.class, rootComponent)`. [source,java] ---- // Get the TextField in the current view -TextField nameField = $view(TextField.class).single(); +TextField nameField = findInView(TextField.class).single(); // Get the TextField nested in a container -TextField nameField = $(TextField.class, view.formLayout).single(); +TextField nameField = find(TextField.class, view.formLayout).single(); ---- The query object has many filtering methods that can be used to refine the search. @@ -45,14 +48,14 @@ The query object has many filtering methods that can be used to refine the searc [source,java] ---- // Get the TextField with the given label -TextField nameField = $view(TextField.class) +TextField nameField = findInView(TextField.class) .withPropertyValue(TextField::getLabel, "First name") .single(); // Get all TextFields in the view that satisfy the conditions Predicate fieldHasNotValue = field -> field.getOptionalValue().isEmpty(); Predicate fieldIsInvalid = TextField::isInvalid; -List textField = $view(TextField.class) +List textField = findInView(TextField.class) .withCondition(fieldHasNotValue.or(fieldIsInvalid)) .all(); ---- @@ -127,13 +130,13 @@ Here are a few examples: [source,java] ---- // Find a button by its text -Button save = $(Button.class).withText("Save").single(); +Button save = find(Button.class).withText("Save").single(); // Find a TextField by CSS class -TextField styled = $(TextField.class).withClassName("highlighted").single(); +TextField styled = find(TextField.class).withClassName("highlighted").single(); // Find checkboxes with a specific value -Checkbox checked = $(Checkbox.class).withValue(true).single(); +Checkbox checked = find(Checkbox.class).withValue(true).single(); ---- @@ -143,7 +146,7 @@ Use [methodname]`exists()` to check whether a query has results without throwing [source,java] ---- -if ($(Notification.class).exists()) { +if (find(Notification.class).exists()) { // A notification is open } ---- @@ -156,13 +159,13 @@ You can assert the number of results directly in the query chain: [source,java] ---- // Expect exactly 3 text fields -List fields = $(TextField.class).withResultsSize(3).all(); +List fields = find(TextField.class).withResultsSize(3).all(); // Expect between 1 and 5 results -List