Package org.fluentlenium.core.components
Class ComponentsManager
- java.lang.Object
-
- org.fluentlenium.core.components.AbstractComponentInstantiator
-
- org.fluentlenium.core.components.ComponentsManager
-
- All Implemented Interfaces:
ComponentInstantiator
,ComponentsAccessor
,ProxyElementListener
public class ComponentsManager extends AbstractComponentInstantiator implements ComponentInstantiator, ComponentsAccessor, ProxyElementListener
Manage living components for a WebDriver instance.A component is an Object implementing no particular interface, but capable of wrapping a
WebElement
.FluentWebElement
is the most common component.
-
-
Constructor Summary
Constructors Constructor Description ComponentsManager(FluentControl control)
Creates a new components manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addComponentsListener(ComponentsListener listener)
Add a component listener to be notified when a component is registered or unregistered.<L extends java.util.List<T>,T>
LasComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elementList)
Create and register a new list of component from the given element iterable.protected void
fireComponentRegistered(org.openqa.selenium.WebElement element, java.lang.Object component)
Fire component registered event.protected void
fireComponentReleased(org.openqa.selenium.WebElement element, java.lang.Object component)
Fire component released event.java.util.Set<java.lang.Object>
getComponents(org.openqa.selenium.WebElement element)
Get the related components from the given element.ComponentInstantiator
getInstantiator()
Get the component instantiator used by this components manager.boolean
isComponentClass(java.lang.Class<?> componentClass)
Check if this class is a component class.boolean
isComponentListClass(java.lang.Class<? extends java.util.List<?>> componentListClass)
Check if this class is a component list class.<T> T
newComponent(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement element)
Create and register a new component of the provided type from the givenWebElement
.<L extends java.util.List<T>,T>
LnewComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, java.util.List<T> componentsList)
Create and register a new list of component from the given component list.void
proxyElementFound(java.lang.Object proxy, org.openqa.selenium.support.pagefactory.ElementLocator locator, java.util.List<org.openqa.selenium.WebElement> elements)
Invoked when proxy element search is over and elements were found.void
proxyElementSearch(java.lang.Object proxy, org.openqa.selenium.support.pagefactory.ElementLocator locator)
Invoked when proxy element search is starting.void
release()
Release this manager.boolean
removeComponentsListener(ComponentsListener listener)
Remove a component listener.-
Methods inherited from class org.fluentlenium.core.components.AbstractComponentInstantiator
asComponentList, asComponentList, asComponentList, asComponentList, asComponentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, newComponentList, newComponentList, newComponentList, newComponentList, newComponentList, newFluent, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fluentlenium.core.components.ComponentInstantiator
asComponentList, asComponentList, asComponentList, asComponentList, asComponentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, newComponentList, newComponentList, newComponentList, newComponentList, newComponentList, newFluent, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList
-
-
-
-
Constructor Detail
-
ComponentsManager
public ComponentsManager(FluentControl control)
Creates a new components manager.- Parameters:
control
- control interface
-
-
Method Detail
-
getInstantiator
public ComponentInstantiator getInstantiator()
Get the component instantiator used by this components manager.- Returns:
- component instantiator
-
getComponents
public java.util.Set<java.lang.Object> getComponents(org.openqa.selenium.WebElement element)
Description copied from interface:ComponentsAccessor
Get the related components from the given element.- Specified by:
getComponents
in interfaceComponentsAccessor
- Parameters:
element
- selenium element- Returns:
- components wrapping the given selenium element
-
isComponentClass
public boolean isComponentClass(java.lang.Class<?> componentClass)
Description copied from interface:ComponentInstantiator
Check if this class is a component class.- Specified by:
isComponentClass
in interfaceComponentInstantiator
- Parameters:
componentClass
- class to check- Returns:
- true if this class is a component class, false otherwise
-
isComponentListClass
public boolean isComponentListClass(java.lang.Class<? extends java.util.List<?>> componentListClass)
Description copied from interface:ComponentInstantiator
Check if this class is a component list class.- Specified by:
isComponentListClass
in interfaceComponentInstantiator
- Parameters:
componentListClass
- class to check- Returns:
- true if this class is a component list class, false otherwise
-
newComponent
public <T> T newComponent(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement element)
Description copied from interface:ComponentInstantiator
Create and register a new component of the provided type from the givenWebElement
.- Specified by:
newComponent
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- type of the componentelement
- wrapped element- Returns:
- new instance of the component
-
addComponentsListener
public boolean addComponentsListener(ComponentsListener listener)
Description copied from interface:ComponentsAccessor
Add a component listener to be notified when a component is registered or unregistered.- Specified by:
addComponentsListener
in interfaceComponentsAccessor
- Parameters:
listener
- components listener- Returns:
- true if listener is added
-
removeComponentsListener
public boolean removeComponentsListener(ComponentsListener listener)
Description copied from interface:ComponentsAccessor
Remove a component listener.- Specified by:
removeComponentsListener
in interfaceComponentsAccessor
- Parameters:
listener
- components listener to remove- Returns:
- true if listener is removed
-
fireComponentRegistered
protected void fireComponentRegistered(org.openqa.selenium.WebElement element, java.lang.Object component)
Fire component registered event.- Parameters:
element
- underlying elementcomponent
- registered component
-
fireComponentReleased
protected void fireComponentReleased(org.openqa.selenium.WebElement element, java.lang.Object component)
Fire component released event.- Parameters:
element
- underlying elementcomponent
- released component
-
newComponentList
public <L extends java.util.List<T>,T> L newComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, java.util.List<T> componentsList)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given component list.- Specified by:
newComponentList
in interfaceComponentInstantiator
- Type Parameters:
L
- type of the listT
- type of the component- Parameters:
listClass
- type of the listcomponentClass
- type of the componentcomponentsList
- components list- Returns:
- new list of components
-
asComponentList
public <L extends java.util.List<T>,T> L asComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elementList)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Overrides:
asComponentList
in classAbstractComponentInstantiator
- Type Parameters:
L
- type of the listT
- type of the component- Parameters:
listClass
- type of the listcomponentClass
- type of the componentelementList
- elements- Returns:
- new list of components
-
proxyElementSearch
public void proxyElementSearch(java.lang.Object proxy, org.openqa.selenium.support.pagefactory.ElementLocator locator)
Description copied from interface:ProxyElementListener
Invoked when proxy element search is starting.- Specified by:
proxyElementSearch
in interfaceProxyElementListener
- Parameters:
proxy
- proxylocator
- element locator
-
proxyElementFound
public void proxyElementFound(java.lang.Object proxy, org.openqa.selenium.support.pagefactory.ElementLocator locator, java.util.List<org.openqa.selenium.WebElement> elements)
Description copied from interface:ProxyElementListener
Invoked when proxy element search is over and elements were found.- Specified by:
proxyElementFound
in interfaceProxyElementListener
- Parameters:
proxy
- proxylocator
- element locatorelements
- found elements
-
release
public void release()
Release this manager.
-
-