Class LocatorJ
- java.lang.Object
-
- com.github.mvysny.kaributesting.v10.LocatorJ
-
public class LocatorJ extends java.lang.ObjectTo use this class, don't forget to addimport static com.github.karibu.testing.LocatorJ.*;to your test class.
-
-
Constructor Summary
Constructors Constructor Description LocatorJ()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends com.vaadin.flow.component.Component>
void_assert(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, int count)Expects that there are exactlycountVISIBLE components of given class.static <T extends com.vaadin.flow.component.Component>
void_assert(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, int count, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are exactlycountVISIBLE components of given class matching given spec.static <T extends com.vaadin.flow.component.Component>
void_assert(@NotNull java.lang.Class<T> clazz, int count)Expects that there are exactlycountVISIBLE components in the current UI matchblock.static <T extends com.vaadin.flow.component.Component>
void_assert(@NotNull java.lang.Class<T> clazz, int count, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are exactlycountVISIBLE components in the current UI of given class which matches spec.static void_assertNoDialogs()Expects that there are no dialogs shown.static <T extends com.vaadin.flow.component.Component>
void_assertNone(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz)Expects that there are no VISIBLE components of given class.static <T extends com.vaadin.flow.component.Component>
void_assertNone(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are no VISIBLE components of given class matching given spec.static <T extends com.vaadin.flow.component.Component>
void_assertNone(@NotNull java.lang.Class<T> clazz)Expects that there are no VISIBLE components in the current UI of given class.static <T extends com.vaadin.flow.component.Component>
void_assertNone(@NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are no VISIBLE components in the current UI of given class which matches spec.static <T extends com.vaadin.flow.component.Component>
void_assertOne(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz)Expects that there is exactly one VISIBLE components of given class.static <T extends com.vaadin.flow.component.Component>
void_assertOne(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there is exactly one VISIBLE components of given class matching given spec.static <T extends com.vaadin.flow.component.Component>
void_assertOne(@NotNull java.lang.Class<T> clazz)Expects that there is exactly ono VISIBLE components in the current UI of given class.static <T extends com.vaadin.flow.component.Component>
void_assertOne(@NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there is exactly one VISIBLE components in the current UI of given class which matches spec.static void_click(@NotNull com.vaadin.flow.component.button.Button receiver)Clicks the button, but only if it is actually possible to do so by the user.static <T extends com.vaadin.flow.component.Component>
java.util.List<T>_find(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz)Finds a list of VISIBLE components of given class.static <T extends com.vaadin.flow.component.Component>
java.util.List<T>_find(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a list of VISIBLE components of given class which matches given spec.static <T extends com.vaadin.flow.component.Component>
java.util.List<T>_find(@NotNull java.lang.Class<T> clazz)Finds a list of VISIBLE components of given class.static <T extends com.vaadin.flow.component.Component>
java.util.List<T>_find(@NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a list of VISIBLE components of given class.static <C extends com.vaadin.flow.component.AbstractField<C,V>,V>
void_fireValueChange(C receiver)Fires a value change event which "comes from the client".static <C extends com.vaadin.flow.component.AbstractField<C,V>,V>
void_fireValueChange(C receiver, boolean fromClient)Fires a value change event which "comes from the client".static <T extends com.vaadin.flow.component.Component>
T_get(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz)Finds a VISIBLE component of given type which matches given class.static <T extends com.vaadin.flow.component.Component>
T_get(@NotNull com.vaadin.flow.component.Component receiver, @NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a VISIBLE component in the current UI of given clazz which matches given spec.static <T extends com.vaadin.flow.component.Component>
T_get(@NotNull java.lang.Class<T> clazz)Finds a VISIBLE component of given type which matches given class.static <T extends com.vaadin.flow.component.Component>
T_get(@NotNull java.lang.Class<T> clazz, @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a VISIBLE component in the current UI of given clazz which matches given spec.static <V,E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<V>>
void_setValue(@NotNull com.vaadin.flow.component.HasValue<E,V> receiver, V value)Sets the value of given component, but only if it is actually possible to do so by the user.
-
-
-
Method Detail
-
_get
@NotNull public static <T extends com.vaadin.flow.component.Component> T _get(@NotNull @NotNull java.lang.Class<T> clazz)Finds a VISIBLE component of given type which matches given class.UI.getCurrent()all of its descendants are searched.- Parameters:
clazz- the component class- Returns:
- the only matching component, never null.
- Throws:
java.lang.IllegalArgumentException- if no component matched, or if more than one component matches.
-
_get
@NotNull public static <T extends com.vaadin.flow.component.Component> T _get(@NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a VISIBLE component in the current UI of given clazz which matches given spec. TheUI.getCurrent()and all of its descendants are searched.Example:
import static com.github.karibu.testing.LocatorJ.*; _get(TextField.class, spec -> spec.withCaption("Name:").withId("name"));- Parameters:
clazz- the component must be of this class.spec- allows you to add search criterion.- Returns:
- the only matching component, never null.
- Throws:
java.lang.IllegalArgumentException- if no component matched, or if more than one component matches.
-
_get
@NotNull public static <T extends com.vaadin.flow.component.Component> T _get(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz)Finds a VISIBLE component of given type which matches given class. The receiver and all of its descendants are searched.- Parameters:
receiver- the parent layout to search in, not null.clazz- the component class- Returns:
- the only matching component, never null.
- Throws:
java.lang.IllegalArgumentException- if no component matched, or if more than one component matches.
-
_get
@NotNull public static <T extends com.vaadin.flow.component.Component> T _get(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a VISIBLE component in the current UI of given clazz which matches given spec. The receiver and all of its descendants are searched. Example:import static com.github.karibu.testing.LocatorJ.*; _get(layout, TextField.class, spec -> spec.withCaption("Name:").withId("name"));- Parameters:
receiver- the parent layout to search in, not null.clazz- the component must be of this class.spec- allows you to add search criterion.- Returns:
- the only matching component, never null.
- Throws:
java.lang.IllegalArgumentException- if no component matched, or if more than one component matches.
-
_click
public static void _click(@NotNull @NotNull com.vaadin.flow.component.button.Button receiver)Clicks the button, but only if it is actually possible to do so by the user. If the button is read-only or disabled, an exception is thrown.- Throws:
java.lang.IllegalStateException- if the button was not visible or not enabled.
-
_setValue
public static <V,E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<V>> void _setValue(@NotNull @NotNull com.vaadin.flow.component.HasValue<E,V> receiver, @Nullable V value)Sets the value of given component, but only if it is actually possible to do so by the user. If the component is read-only or disabled, an exception is thrown. The function fires the value change event; theHasValue.ValueChangeEvent.isFromClient()will return false indicating that the event came from the server. If this is not desired, depending on your code, it may be possible to call_fireValueChange(AbstractField, boolean)withfromClient=trueinstead.- Throws:
java.lang.IllegalStateException- if the field was not visible, not enabled or was read-only.
-
_fireValueChange
public static <C extends com.vaadin.flow.component.AbstractField<C,V>,V> void _fireValueChange(@NotNull C receiver, boolean fromClient)Fires a value change event which "comes from the client". The event is only fired if it is actually possible to do so by the user. If the component is read-only or disabled, an exception is thrown.- Parameters:
fromClient- whether the event comes from the client or not.- Throws:
java.lang.IllegalStateException- if the field was not visible, not enabled or was read-only.
-
_fireValueChange
public static <C extends com.vaadin.flow.component.AbstractField<C,V>,V> void _fireValueChange(@NotNull C receiver)Fires a value change event which "comes from the client". The event is only fired if it is actually possible to do so by the user. If the component is read-only or disabled, an exception is thrown.- Throws:
java.lang.IllegalStateException- if the field was not visible, not enabled or was read-only.
-
_find
public static <T extends com.vaadin.flow.component.Component> java.util.List<T> _find(@NotNull @NotNull java.lang.Class<T> clazz)Finds a list of VISIBLE components of given class.UI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the requested type of returned components.- Returns:
- the list of matching components, may be empty.
-
_find
public static <T extends com.vaadin.flow.component.Component> java.util.List<T> _find(@NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a list of VISIBLE components of given class.UI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the requested type of returned components.- Returns:
- the list of matching components, may be empty.
-
_find
public static <T extends com.vaadin.flow.component.Component> java.util.List<T> _find(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz)Finds a list of VISIBLE components of given class. Given component and all of its descendants are searched.- Parameters:
receiver- search this component and all of its descendants.clazz- the requested type of returned components.- Returns:
- the list of matching components, may be empty.
-
_find
public static <T extends com.vaadin.flow.component.Component> java.util.List<T> _find(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Finds a list of VISIBLE components of given class which matches given spec. Given component and all of its descendants are searched.- Parameters:
receiver- search this component and all of its descendants.clazz- the requested type of returned components.spec- configures the search criteria.- Returns:
- the list of matching components, may be empty.
-
_assertNone
public static <T extends com.vaadin.flow.component.Component> void _assertNone(@NotNull @NotNull java.lang.Class<T> clazz)Expects that there are no VISIBLE components in the current UI of given class. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the requested type of matched components.- Throws:
java.lang.IllegalArgumentException- if one or more components matched.
-
_assertNone
public static <T extends com.vaadin.flow.component.Component> void _assertNone(@NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are no VISIBLE components in the current UI of given class which matches spec. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the requested type of matched components.spec- configures the search criteria.- Throws:
java.lang.IllegalArgumentException- if one or more components matched.
-
_assertNone
public static <T extends com.vaadin.flow.component.Component> void _assertNone(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz)Expects that there are no VISIBLE components of given class. Given component and all of its descendants are searched.- Parameters:
receiver- search this component and all of its descendants.clazz- the requested type of returned components.- Throws:
java.lang.IllegalArgumentException- if one or more components matched.
-
_assertNone
public static <T extends com.vaadin.flow.component.Component> void _assertNone(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are no VISIBLE components of given class matching given spec. Given component and all of its descendants are searched.- Parameters:
receiver- search this component and all of its descendants.clazz- the requested type of returned components.spec- configures the search criteria.- Throws:
java.lang.IllegalArgumentException- if one or more components matched.
-
_assertOne
public static <T extends com.vaadin.flow.component.Component> void _assertOne(@NotNull @NotNull java.lang.Class<T> clazz)Expects that there is exactly ono VISIBLE components in the current UI of given class. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the component must be of this class.- Throws:
java.lang.AssertionError- if none, or more than one components matched.
-
_assertOne
public static <T extends com.vaadin.flow.component.Component> void _assertOne(@NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there is exactly one VISIBLE components in the current UI of given class which matches spec. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the component must be of this class.spec- allows you to add search criterion.- Throws:
java.lang.AssertionError- if none, or more than one components matched.
-
_assertOne
public static <T extends com.vaadin.flow.component.Component> void _assertOne(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz)Expects that there is exactly one VISIBLE components of given class. Given component and all of its descendants are searched.- Parameters:
receiver- the parent layout to search in, not null.clazz- the component must be of this class.- Throws:
java.lang.AssertionError- if none, or more than one components matched.
-
_assertOne
public static <T extends com.vaadin.flow.component.Component> void _assertOne(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there is exactly one VISIBLE components of given class matching given spec. Given component and all of its descendants are searched.- Parameters:
receiver- the parent layout to search in, not null.clazz- the component must be of this class.spec- allows you to add search criterion.- Throws:
java.lang.AssertionError- if none, or more than one components matched.
-
_assert
public static <T extends com.vaadin.flow.component.Component> void _assert(@NotNull @NotNull java.lang.Class<T> clazz, int count)Expects that there are exactlycountVISIBLE components in the current UI matchblock. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the component must be of this class.count- this count of components must match- Throws:
java.lang.AssertionError- if incorrect count of component matched.
-
_assert
public static <T extends com.vaadin.flow.component.Component> void _assert(@NotNull @NotNull java.lang.Class<T> clazz, int count, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are exactlycountVISIBLE components in the current UI of given class which matches spec. TheUI.getCurrent()and all of its descendants are searched.- Parameters:
clazz- the component must be of this class.count- this count of components must matchspec- allows you to add search criterion.- Throws:
java.lang.AssertionError- if incorrect count of component matched.
-
_assert
public static <T extends com.vaadin.flow.component.Component> void _assert(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, int count)Expects that there are exactlycountVISIBLE components of given class. Given component and all of its descendants are searched.- Parameters:
receiver- the parent layout to search in, not null.clazz- the component must be of this class.count- this count of components must match- Throws:
java.lang.AssertionError- if incorrect count of component matched.
-
_assert
public static <T extends com.vaadin.flow.component.Component> void _assert(@NotNull @NotNull com.vaadin.flow.component.Component receiver, @NotNull @NotNull java.lang.Class<T> clazz, int count, @NotNull @NotNull java.util.function.Consumer<SearchSpecJ<T>> spec)Expects that there are exactlycountVISIBLE components of given class matching given spec. Given component and all of its descendants are searched.- Parameters:
receiver- the parent layout to search in, not null.clazz- the component must be of this class.count- this count of components must matchspec- allows you to add search criterion.- Throws:
java.lang.AssertionError- if incorrect count of component matched.
-
_assertNoDialogs
public static void _assertNoDialogs()
Expects that there are no dialogs shown.
-
-