Package com.vaadin.browserless.internal
Class Locator
java.lang.Object
com.vaadin.browserless.internal.Locator
Functions for looking up components in the component tree.
For internal use only. May be renamed or removed in a future release.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends com.vaadin.flow.component.Component>
void_expect(com.vaadin.flow.component.Component receiver, Class<T> clazz, int count, Consumer<SearchSpec<T>> block) Expects that there are exactlycountVISIBLE components of givenclazzmatchblock.static <T extends com.vaadin.flow.component.Component>
void_expect(Class<T> clazz, int count, Consumer<SearchSpec<T>> block) Expects that there are exactlycountVISIBLE components in the current UI with givenclazzmatchblock.static void_expectInternalServerError(String expectedErrorMessage) Asserts that theInternalServerErrorpage is currently being shown, optionally with givenexpectedErrorMessage.static voidExpects that there are no dialogs shown.static <T extends com.vaadin.flow.component.Component>
void_expectNone(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there are no VISIBLE components of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
void_expectNone(Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there are no VISIBLE components in the current UI of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
void_expectOne(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there is exactly one VISIBLE components of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
void_expectOne(Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there is exactly one VISIBLE components in the current UI of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
List<T> _find(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a list of VISIBLE components of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
List<T> _find(Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a list of VISIBLE components of givenclazzwhich matchesblock.static <T extends com.vaadin.flow.component.Component>
T_get(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a VISIBLE component of givenclazzwhich matches givenblock.static <T extends com.vaadin.flow.component.Component>
T_get(Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a VISIBLE component in the current UI of givenclazzwhich matches givenblock.static Iterable<com.vaadin.flow.component.Component> _walkAll(com.vaadin.flow.component.Component receiver) Walks the component child/descendant tree, depth-first: first the component, then its descendants, then its next sibling.filterNotBlank(Iterable<String> strings) Returns the non-null, non-blank strings of given iterable.static StringReturns the browser's current path.
-
Method Details
-
filterNotBlank
Returns the non-null, non-blank strings of given iterable.- Parameters:
strings- the strings to filter, not null.- Returns:
- the non-null, non-blank strings.
-
_get
public static <T extends com.vaadin.flow.component.Component> T _get(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a VISIBLE component of givenclazzwhich matches givenblock. This component and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
receiver- the component to search in.clazz- the component must be of this class.block- the search specification- Returns:
- the only matching component, never null.
- Throws:
AssertionError- if no component matched, or if more than one component matches.
-
_get
public static <T extends com.vaadin.flow.component.Component> T _get(Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a VISIBLE component in the current UI of givenclazzwhich matches givenblock. The current UI and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
clazz- the component must be of this class.block- the search specification- Returns:
- the only matching component, never null.
- Throws:
AssertionError- if no component matched, or if more than one component matches.
-
_find
public static <T extends com.vaadin.flow.component.Component> List<T> _find(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a list of VISIBLE components of givenclazzwhich matchesblock. This component and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
receiver- the component to search in.clazz- the component must be of this class.block- the search specification- Returns:
- the list of matching components, may be empty.
- Throws:
AssertionError- if the number of matching components is not within the expected count.
-
_find
public static <T extends com.vaadin.flow.component.Component> List<T> _find(Class<T> clazz, Consumer<SearchSpec<T>> block) Finds a list of VISIBLE components of givenclazzwhich matchesblock. TheUI.getCurrent()and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
clazz- the component must be of this class.block- the search specification- Returns:
- the list of matching components, may be empty.
-
_walkAll
public static Iterable<com.vaadin.flow.component.Component> _walkAll(com.vaadin.flow.component.Component receiver) Walks the component child/descendant tree, depth-first: first the component, then its descendants, then its next sibling.- Parameters:
receiver- the root component.- Returns:
- the iterable over the component and all of its descendants.
-
_expectNone
public static <T extends com.vaadin.flow.component.Component> void _expectNone(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there are no VISIBLE components of givenclazzwhich matchesblock. This component and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
receiver- the component to search in.clazz- the component class.block- the search specification- Throws:
AssertionError- if one or more components matched.
-
_expectNoDialogs
public static void _expectNoDialogs()Expects that there are no dialogs shown. The dialog types come from the registeredComponentSupportimplementations.- Throws:
AssertionError- if a dialog is shown.IllegalStateException- if noComponentSupportreports any dialog type.
-
_expectNone
public static <T extends com.vaadin.flow.component.Component> void _expectNone(Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there are no VISIBLE components in the current UI of givenclazzwhich matchesblock. The current UI and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
clazz- the component class.block- the search specification- Throws:
AssertionError- if one or more components matched.
-
_expectOne
public static <T extends com.vaadin.flow.component.Component> void _expectOne(com.vaadin.flow.component.Component receiver, Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there is exactly one VISIBLE components of givenclazzwhich matchesblock. This component and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
receiver- the component to search in.clazz- the component class.block- the search specification- Throws:
AssertionError- if none, or more than one components matched.
-
_expectOne
public static <T extends com.vaadin.flow.component.Component> void _expectOne(Class<T> clazz, Consumer<SearchSpec<T>> block) Expects that there is exactly one VISIBLE components in the current UI of givenclazzwhich matchesblock. The current UI and all of its descendants are searched.- Type Parameters:
T- the component type- Parameters:
clazz- the component class.block- the search specification- Throws:
AssertionError- if none, or more than one components matched.
-
_expect
public static <T extends com.vaadin.flow.component.Component> void _expect(com.vaadin.flow.component.Component receiver, Class<T> clazz, int count, Consumer<SearchSpec<T>> block) Expects that there are exactlycountVISIBLE components of givenclazzmatchblock. This component and all of its descendants are searched.Special cases: for asserting one component use
_expectOne. For asserting no components use_expectNone.- Type Parameters:
T- the component type- Parameters:
receiver- the component to search in.clazz- the component class.count- the expected number of matching components.block- the search specification- Throws:
AssertionError- if incorrect count of component matched.
-
_expect
public static <T extends com.vaadin.flow.component.Component> void _expect(Class<T> clazz, int count, Consumer<SearchSpec<T>> block) Expects that there are exactlycountVISIBLE components in the current UI with givenclazzmatchblock. The current UI and all of its descendants are searched.Special cases: for asserting one component use
_expectOne. For asserting no components use_expectNone. They provide a better error message in case of a failure, and also communicate your intent as a test writer better in the test code.- Type Parameters:
T- the component type- Parameters:
clazz- the component class.count- the expected number of matching components.block- the search specification- Throws:
AssertionError- if incorrect count of component matched.
-
_expectInternalServerError
Asserts that theInternalServerErrorpage is currently being shown, optionally with givenexpectedErrorMessage.- Parameters:
expectedErrorMessage- the text the error message must contain; an empty string matches any message.
-
getCurrentPath
Returns the browser's current path. Returns null if there is no current UI.- Returns:
- the current path with query parameters, or null.
-