Package io.fluentlenium.core.domain
Class FluentListImpl<E extends FluentWebElement>
java.lang.Object
io.fluentlenium.core.domain.ListImpl<T>
io.fluentlenium.core.domain.DelegatingList<T>
io.fluentlenium.core.domain.ComponentList<E>
io.fluentlenium.core.domain.FluentListImpl<E>
- Type Parameters:
E
- type of fluent element the list contains
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
,FluentActions<FluentList<E>,
,E> FluentJavascriptActions
,LazyComponents
,FluentList<E>
,WrapsElements
,HookControl<FluentList<E>>
,FluentLabel<FluentList<E>>
,FluentProxyState<FluentList<E>>
,SearchControl<E>
public class FluentListImpl<E extends FluentWebElement>
extends ComponentList<E>
implements FluentList<E>
Default implementation of
FluentList
and ComponentList
.
It offers convenience methods to work with a collection of elements, like click(), submit(), value() ...
It also offers capability to add labels and hooks to an object having this type.
-
Field Summary
Fields inherited from class io.fluentlenium.core.domain.ComponentList
componentClass, control, instantiator, proxy
Fields inherited from class io.fluentlenium.core.domain.DelegatingList
list
-
Constructor Summary
ConstructorDescriptionFluentListImpl
(Class<E> componentClass, List<E> list, FluentControl control, ComponentInstantiator instantiator) Creates a new fluent list. -
Method Summary
Modifier and TypeMethodDescriptionWrap raw selenium elements into a list of elements.<T extends FluentWebElement>
FluentList<T>Wrap all underlying elements in a component.await()
Build a wait object to wait for a condition of this element list.Build a condition object on this element list that will match if each underlying element match, automatically waiting for condition to be verified.Build a condition object on this element list that will match if one or more underlying element match, automatically waiting for condition to be verified.void
clear()
Clear visible elements on the listclearAll()
Clear all elements on the listClear all React elements on the listvoid
CallsList.clear()
from underlying List implementation.click()
Click on all elements on the list Only the clickable elements are clickedcontext click on all elements on the list Only the clickable elements are clickedint
count()
Count elements without actually loading the lazy list.double click on all elements on the list Only the clickable elements are clickedeach()
Build a condition object on this element list that will match if each underlying element match.el
(org.openqa.selenium.WebElement rawElement) Wrap existing raw selenium element into an element.fill()
Construct a Fill Builder in order to allow easy fill of visible input fields.Construct a Fill Select Builder in order to allow easy fill of visible input fields.find
(String selector, SearchFilter... filters) find elements into the children with the corresponding filtersWrap raw selenium elements into a list of elements.find
(SearchFilter... filters) find elements in the children with the corresponding filtersfind
(org.openqa.selenium.By locator, SearchFilter... filters) Find list of elements with Selenium locator and filters.first()
Retrieve the first element.frame()
Select a frame using this element.get
(int index) index
(int index) Retrieve an element at given index.last()
Retrieve the last element.boolean
loaded()
Check if the element is loaded.modifyAttribute
(String attributeName, String attributeValue) Modifies attributes of first element onlynoHook()
Disable all hooks from actual element.noHook
(Class<? extends FluentHook>... hooks) Disable given hook from actual element.<R> R
noHook
(Class<? extends FluentHook> hook, Function<FluentList<E>, R> function) Invoke a function with no hook.<R> R
noHook
(Function<FluentList<E>, R> function) Invoke a function with no hook.Creates a new element locator instance with all hooks disabled.noHookInstance
(Class<? extends FluentHook>... hooks) Creates a new element locator instance with given hook disabled.now()
Search for the element now, actually performing the search on theWebDriver
.now
(boolean force) Search for the element now, actually performing the search on theWebDriver
.one()
Build a condition object on this element list that will match if one or more underlying element match.optional()
Builds an optional.boolean
present()
Check if the element is present in the DOM.reset()
Reset the element.Retore hooks that were defined initially.Scrolls to first element of listscrollIntoView
(boolean alignWithTop) Scrolls to first element of listScrolls to first element of listsingle()
Retrieve the first element and checks is it exactly one element in the listsubmit()
submit on all elements on the list Only the visible elements are submittedtoString()
Helper method that: a) waits at most 5 seconds for element b) scrolls centrally into it c) clicks on itwaitAndClick
(Duration duration) Helper method that: a) waits for element b) scrolls centrally into it c) clicks on it<O,
H extends FluentHook<O>>
FluentList<E>Enable a hook with default options.<O,
H extends FluentHook<O>>
FluentList<E>Enable a hook with given options.Apply a label that will be displayed as the representation of this object for error message.withLabelHint
(String... labelHint) Add a label hint that will be appended to the representation of this object for error message.Fill all elements on the list with the corresponding cell in the with array.Methods inherited from class io.fluentlenium.core.domain.ComponentList
addLazyComponentsListener, getWrappedElements, isLazy, isLazyInitialized, removeLazyComponentsListener
Methods inherited from class io.fluentlenium.core.domain.DelegatingList
getList
Methods inherited from class io.fluentlenium.core.domain.ListImpl
add, add, addAll, addAll, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface io.fluentlenium.core.domain.FluentList
attributes, dimensions, hoverOver, ids, names, tagNames, textContents, texts, toElements, values
Methods inherited from interface java.util.List
add, add, addAll, addAll, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
FluentListImpl
public FluentListImpl(Class<E> componentClass, List<E> list, FluentControl control, ComponentInstantiator instantiator) Creates a new fluent list.- Parameters:
componentClass
- component classlist
- list of fluent elementcontrol
- control interfaceinstantiator
- component instantiator
-
-
Method Details
-
await
Description copied from interface:FluentList
Build a wait object to wait for a condition of this element list.- Specified by:
await
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- a wait object
-
first
Description copied from interface:FluentList
Retrieve the first element.- Specified by:
first
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- first element
-
single
Description copied from interface:FluentList
Retrieve the first element and checks is it exactly one element in the list- Specified by:
single
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- first element
-
last
Description copied from interface:FluentList
Retrieve the last element.- Specified by:
last
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- last element
-
get
- Specified by:
get
in interfaceList<E extends FluentWebElement>
- Overrides:
get
in classListImpl<E extends FluentWebElement>
-
index
Description copied from interface:FluentList
Retrieve an element at given index.- Specified by:
index
in interfaceFluentList<E extends FluentWebElement>
- Parameters:
index
- position of the element to retrieve- Returns:
- element at given index
-
count
public int count()Description copied from interface:FluentList
Count elements without actually loading the lazy list.This method ignore defined hooks.
- Specified by:
count
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- elements count
-
present
public boolean present()Description copied from interface:FluentProxyState
Check if the element is present in the DOM.- Specified by:
present
in interfaceFluentProxyState<E extends FluentWebElement>
- Returns:
- true if the element is present, false otherwise
-
now
Description copied from interface:FluentProxyState
Search for the element now, actually performing the search on theWebDriver
.It has no effect if the element is already loaded.
- Specified by:
now
in interfaceFluentProxyState<E extends FluentWebElement>
- Returns:
- this object reference to chain calls.
-
now
Description copied from interface:FluentProxyState
Search for the element now, actually performing the search on theWebDriver
.It has no effect if the element is already loaded.
- Specified by:
now
in interfaceFluentProxyState<E extends FluentWebElement>
- Parameters:
force
- force the search even if element is already loaded- Returns:
- this object reference to chain calls.
-
reset
Description copied from interface:FluentProxyState
Reset the element. Subsequent calls will perform the search again, instead of using the cached result.- Specified by:
reset
in interfaceFluentProxyState<E extends FluentWebElement>
- Returns:
- this object reference to chain calls.
-
loaded
public boolean loaded()Description copied from interface:FluentProxyState
Check if the element is loaded.- Specified by:
loaded
in interfaceFluentProxyState<E extends FluentWebElement>
- Returns:
- true if the element is loaded, false otherwise
-
click
Description copied from interface:FluentList
Click on all elements on the list Only the clickable elements are clicked- Specified by:
click
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Specified by:
click
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- the current instance of FluentList to provide capability for chaining calls
- See Also:
-
WebElement.click()
-
doubleClick
Description copied from interface:FluentList
double click on all elements on the list Only the clickable elements are clicked- Specified by:
doubleClick
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Specified by:
doubleClick
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- the current instance of FluentList to provide capability for chaining calls
-
contextClick
Description copied from interface:FluentList
context click on all elements on the list Only the clickable elements are clicked- Specified by:
contextClick
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Specified by:
contextClick
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- the current instance of FluentList to provide capability for chaining calls
-
waitAndClick
Description copied from interface:FluentActions
Helper method that: a) waits at most 5 seconds for element b) scrolls centrally into it c) clicks on it- Specified by:
waitAndClick
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Returns:
- this object reference to chain methods calls
-
waitAndClick
Description copied from interface:FluentActions
Helper method that: a) waits for element b) scrolls centrally into it c) clicks on it- Specified by:
waitAndClick
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Parameters:
duration
- - enabled to override default 5 seconds of waiting- Returns:
- this object reference to chain methods calls
-
write
Description copied from interface:FluentList
Fill all elements on the list with the corresponding cell in the with array. Only the visible elements are filled If there are more elements on the list than in the with array, the last element of the table is repeated- Specified by:
write
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Specified by:
write
in interfaceFluentList<E extends FluentWebElement>
- Parameters:
with
- one or many text to send.- Returns:
- the current instance of FluentList to provide capability for chaining calls
- See Also:
-
WebElement.sendKeys(CharSequence...)
-
clearAll
Description copied from interface:FluentList
Clear all elements on the listOnly the visible elements are cleared.
- Specified by:
clearAll
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- extended by FluentWebElement object
-
clearAllReactInputs
Description copied from interface:FluentList
Clear all React elements on the listOnly the visible elements are cleared.
- Specified by:
clearAllReactInputs
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- extended by FluentWebElement object
-
clearList
public void clearList()Description copied from interface:FluentList
CallsList.clear()
from underlying List implementation.- Specified by:
clearList
in interfaceFluentList<E extends FluentWebElement>
- See Also:
-
each
Description copied from interface:FluentList
Build a condition object on this element list that will match if each underlying element match.- Specified by:
each
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- a condition object
-
one
Description copied from interface:FluentList
Build a condition object on this element list that will match if one or more underlying element match.- Specified by:
one
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- a condition object
-
awaitUntilEach
Description copied from interface:FluentList
Build a condition object on this element list that will match if each underlying element match, automatically waiting for condition to be verified.- Specified by:
awaitUntilEach
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- a condition object
-
awaitUntilOne
Description copied from interface:FluentList
Build a condition object on this element list that will match if one or more underlying element match, automatically waiting for condition to be verified.- Specified by:
awaitUntilOne
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- a condition object
-
submit
Description copied from interface:FluentList
submit on all elements on the list Only the visible elements are submitted- Specified by:
submit
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Specified by:
submit
in interfaceFluentList<E extends FluentWebElement>
- Returns:
- the current instance of FluentList to provide capability for chaining calls
- See Also:
-
WebElement.submit()
-
find
Description copied from interface:SearchControl
Wrap raw selenium elements into a list of elements.- Specified by:
find
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
rawElements
- raw selenium elements- Returns:
- list of element
-
$
Description copied from interface:SearchControl
Wrap raw selenium elements into a list of elements.- Specified by:
$
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
rawElements
- raw selenium elements- Returns:
- list of element
-
el
Description copied from interface:SearchControl
Wrap existing raw selenium element into an element.- Specified by:
el
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
rawElement
- raw selenium element- Returns:
- element
-
find
Description copied from interface:FluentList
find elements into the children with the corresponding filters- Specified by:
find
in interfaceFluentList<E extends FluentWebElement>
- Specified by:
find
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
selector
- element namefilters
- set of filters- Returns:
- extended by FluentWebElement objects list
-
find
Description copied from interface:SearchControl
Find list of elements with Selenium locator and filters.- Specified by:
find
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
locator
- elements locatorfilters
- filters set- Returns:
- list of elements
-
find
Description copied from interface:FluentList
find elements in the children with the corresponding filters- Specified by:
find
in interfaceFluentList<E extends FluentWebElement>
- Specified by:
find
in interfaceSearchControl<E extends FluentWebElement>
- Parameters:
filters
- set of filters- Returns:
- extended by FluentWebElement objects list
-
fill
Description copied from interface:FluentActions
Construct a Fill Builder in order to allow easy fill of visible input fields.- Specified by:
fill
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Returns:
- Fill builder
-
fillSelect
Description copied from interface:FluentActions
Construct a Fill Select Builder in order to allow easy fill of visible input fields.- Specified by:
fillSelect
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Returns:
- Fill select builder
-
frame
Description copied from interface:FluentActions
Select a frame using this element.- Specified by:
frame
in interfaceFluentActions<FluentList<E extends FluentWebElement>,
E extends FluentWebElement> - Returns:
- this object reference to chain methods calls.
-
optional
Description copied from interface:FluentProxyState
Builds an optional. If underlying element is lazy, search will be perfomed when invoking this method.- Specified by:
optional
in interfaceFluentProxyState<E extends FluentWebElement>
- Returns:
- An optional wrapping this.
- See Also:
-
as
Description copied from interface:FluentList
Wrap all underlying elements in a component.- Specified by:
as
in interfaceFluentList<E extends FluentWebElement>
- Type Parameters:
T
- type of component- Parameters:
componentClass
- component class- Returns:
- fluent list of elements as components.
-
clear
public void clear()Description copied from interface:FluentList
Clear visible elements on the list- Specified by:
clear
in interfaceCollection<E extends FluentWebElement>
- Specified by:
clear
in interfaceFluentList<E extends FluentWebElement>
- Specified by:
clear
in interfaceList<E extends FluentWebElement>
- Overrides:
clear
in classListImpl<E extends FluentWebElement>
-
toString
-
withLabel
Description copied from interface:FluentLabel
Apply a label that will be displayed as the representation of this object for error message.- Specified by:
withLabel
in interfaceFluentLabel<E extends FluentWebElement>
- Parameters:
label
- label to use- Returns:
- reference to this object to chain calls
-
withLabelHint
Description copied from interface:FluentLabel
Add a label hint that will be appended to the representation of this object for error message.- Specified by:
withLabelHint
in interfaceFluentLabel<E extends FluentWebElement>
- Parameters:
labelHint
- label hints to add- Returns:
- reference to this object to chain calls
-
noHookInstance
Description copied from interface:HookControl
Creates a new element locator instance with all hooks disabled.- Specified by:
noHookInstance
in interfaceHookControl<E extends FluentWebElement>
- Returns:
- new element locator with hook disabled.
-
noHook
Description copied from interface:HookControl
Disable all hooks from actual element.- Specified by:
noHook
in interfaceHookControl<E extends FluentWebElement>
- Returns:
- this object reference to chain calls
-
withHook
Description copied from interface:HookControl
Enable a hook with default options.- Specified by:
withHook
in interfaceHookControl<E extends FluentWebElement>
- Type Parameters:
O
- Type of the hookH
- Type of the hook options- Parameters:
hook
- hook class to enable- Returns:
- this object reference to chain calls
-
noHook
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<E extends FluentWebElement>
- Type Parameters:
R
- return type- Parameters:
hook
- hook class to disablefunction
- function to invoke- Returns:
- return value of the given function
-
restoreHooks
Description copied from interface:HookControl
Retore hooks that were defined initially.- Specified by:
restoreHooks
in interfaceHookControl<E extends FluentWebElement>
- Returns:
- this object reference to chain calls
-
withHook
Description copied from interface:HookControl
Enable a hook with given options.- Specified by:
withHook
in interfaceHookControl<E extends FluentWebElement>
- Type Parameters:
O
- Type of the hookH
- Type of the hook options- Parameters:
hook
- hook class to enableoptions
- hook options to apply- Returns:
- this object reference to chain calls
-
noHook
Description copied from interface:HookControl
Disable given hook from actual element.- Specified by:
noHook
in interfaceHookControl<E extends FluentWebElement>
- Parameters:
hooks
- hook classes to disable- Returns:
- this object reference to chain calls
-
noHookInstance
Description copied from interface:HookControl
Creates a new element locator instance with given hook disabled.- Specified by:
noHookInstance
in interfaceHookControl<E extends FluentWebElement>
- Parameters:
hooks
- hook classes to disable- Returns:
- new element locator with hook disabled.
-
noHook
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<E extends FluentWebElement>
- Type Parameters:
R
- return type- Parameters:
function
- function to invoke- Returns:
- return value of the given function
-
scrollToCenter
Scrolls to first element of list- Specified by:
scrollToCenter
in interfaceFluentJavascriptActions<E extends FluentWebElement>
- Returns:
- this object reference to chain methods calls
-
scrollIntoView
Scrolls to first element of list- Specified by:
scrollIntoView
in interfaceFluentJavascriptActions<E extends FluentWebElement>
- Parameters:
alignWithTop
- If true, the top of the element will be aligned to the top of the visible area of the scrollable ancestor. If false, the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor.- Returns:
- this object reference to chain methods calls
- See Also:
-
modifyAttribute
Modifies attributes of first element only- Specified by:
modifyAttribute
in interfaceFluentJavascriptActions<E extends FluentWebElement>
- Parameters:
attributeName
- attribute to be changeattributeValue
- new attribute value- Returns:
- this object reference to chain methods calls
-
scrollIntoView
Scrolls to first element of list- Specified by:
scrollIntoView
in interfaceFluentJavascriptActions<E extends FluentWebElement>
- Returns:
- this object reference to chain methods calls
- See Also:
-