Package org.fluentlenium.core.proxy
Class AbstractLocatorHandler<T>
- java.lang.Object
-
- org.fluentlenium.core.proxy.AbstractLocatorHandler<T>
-
- Type Parameters:
T
- type of underlying element or component
- All Implemented Interfaces:
LocatorHandler<T>
,LocatorStatusHandler
- Direct Known Subclasses:
AbstractLocatorAndInvocationHandler
public abstract class AbstractLocatorHandler<T> extends Object implements LocatorHandler<T>
Abstract proxy handler supporting lazy loading and hooks onWebElement
.Contains the locator handling related logic.
-
-
Field Summary
Fields Modifier and Type Field Description protected HookChainBuilder
hookChainBuilder
protected List<HookDefinition<?>>
hookDefinitions
protected List<FluentHook>
hooks
protected org.openqa.selenium.support.pagefactory.ElementLocator
locator
protected T
proxy
protected T
result
-
Constructor Summary
Constructors Constructor Description AbstractLocatorHandler(org.openqa.selenium.support.pagefactory.ElementLocator locator)
Creates a new locator handler.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
addListener(ProxyElementListener listener)
Add a listener for this locator handler.protected void
fireProxyElementFound(T result)
Fire proxy element found event.protected void
fireProxyElementSearch()
Fire proxy element search event.protected abstract org.openqa.selenium.WebElement
getElement()
Get the underlying element.org.openqa.selenium.support.pagefactory.ElementLocator
getHookLocator()
Retrieve the element locator used by this proxy, with hooks applied.protected String
getLazyToString()
Get string representation of not already found element.org.openqa.selenium.support.pagefactory.ElementLocator
getLocator()
Retrieve the element locator used by this proxy, without any hook applied.T
getLocatorResult()
Get the actual result of the locator, if result is not defined and not stale.abstract T
getLocatorResultImpl()
Get the actual result of the locator.protected abstract boolean
isStale()
Get the stale status of the element.boolean
loaded()
Check if this handler has loaded it's result.boolean
present()
Check if the result is present.String
proxyToString(String elementToString)
Get string representation of the proxyboolean
removeListener(ProxyElementListener listener)
Removes a proxy element listener.void
reset()
Reset the loaded data.protected abstract List<org.openqa.selenium.WebElement>
resultToList(T result)
Convert result to a list of selenium element.void
setHooks(HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions)
Apply this hook list.void
setProxy(T proxy)
Set the proxy using this handler.-
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.proxy.LocatorHandler
getInvocationTarget, getMessageContext, noSuchElement, now
-
-
-
-
Field Detail
-
locator
protected final org.openqa.selenium.support.pagefactory.ElementLocator locator
-
hookChainBuilder
protected HookChainBuilder hookChainBuilder
-
hookDefinitions
protected List<HookDefinition<?>> hookDefinitions
-
hooks
protected List<FluentHook> hooks
-
proxy
protected T proxy
-
result
protected T result
-
-
Method Detail
-
addListener
public boolean addListener(ProxyElementListener listener)
Description copied from interface:LocatorHandler
Add a listener for this locator handler.- Specified by:
addListener
in interfaceLocatorHandler<T>
- Parameters:
listener
- listener to add, which will be notified when result is searched and found- Returns:
- true if the listener was added, false otherwise
-
removeListener
public boolean removeListener(ProxyElementListener listener)
Description copied from interface:LocatorHandler
Removes a proxy element listener.- Specified by:
removeListener
in interfaceLocatorHandler<T>
- Parameters:
listener
- listener to remove- Returns:
- true if the listener was removed, false otherwise
-
getLocatorResult
public T getLocatorResult()
Get the actual result of the locator, if result is not defined and not stale.It also raise events.
- Specified by:
getLocatorResult
in interfaceLocatorHandler<T>
- Returns:
- result of the locator
-
setHooks
public void setHooks(HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions)
Description copied from interface:LocatorHandler
Apply this hook list.- Specified by:
setHooks
in interfaceLocatorHandler<T>
- Parameters:
hookChainBuilder
- hook chain builderhookDefinitions
- hook definitions
-
getLocator
public org.openqa.selenium.support.pagefactory.ElementLocator getLocator()
Description copied from interface:LocatorHandler
Retrieve the element locator used by this proxy, without any hook applied.- Specified by:
getLocator
in interfaceLocatorHandler<T>
- Returns:
- element locator
-
getHookLocator
public org.openqa.selenium.support.pagefactory.ElementLocator getHookLocator()
Description copied from interface:LocatorHandler
Retrieve the element locator used by this proxy, with hooks applied.- Specified by:
getHookLocator
in interfaceLocatorHandler<T>
- Returns:
- element locator wrapped with hooks
-
loaded
public boolean loaded()
Description copied from interface:LocatorStatusHandler
Check if this handler has loaded it's result.- Specified by:
loaded
in interfaceLocatorStatusHandler
- Returns:
- true if the result is loaded, false otherwise
-
present
public boolean present()
Description copied from interface:LocatorStatusHandler
Check if the result is present.- Specified by:
present
in interfaceLocatorStatusHandler
- Returns:
- true if result is present, false otherwise
-
reset
public void reset()
Description copied from interface:LocatorStatusHandler
Reset the loaded data.- Specified by:
reset
in interfaceLocatorStatusHandler
-
setProxy
public void setProxy(T proxy)
Set the proxy using this handler.- Parameters:
proxy
- proxy using this handler
-
fireProxyElementSearch
protected void fireProxyElementSearch()
Fire proxy element search event.
-
fireProxyElementFound
protected void fireProxyElementFound(T result)
Fire proxy element found event.- Parameters:
result
- found element
-
getLocatorResultImpl
public abstract T getLocatorResultImpl()
Get the actual result of the locator.- Returns:
- result of the locator
-
resultToList
protected abstract List<org.openqa.selenium.WebElement> resultToList(T result)
Convert result to a list of selenium element.- Parameters:
result
- found result- Returns:
- list of selenium element
-
isStale
protected abstract boolean isStale()
Get the stale status of the element.- Returns:
- true if element is stale, false otherwise
-
getElement
protected abstract org.openqa.selenium.WebElement getElement()
Get the underlying element.- Returns:
- underlying element
-
getLazyToString
protected String getLazyToString()
Get string representation of not already found element.- Returns:
- string representation of not already found element
-
-