Package io.fluentlenium.core.proxy
Class AbstractLocatorHandler<T>
java.lang.Object
io.fluentlenium.core.proxy.AbstractLocatorHandler<T>
- Type Parameters:
T- type of underlying element or component
- All Implemented Interfaces:
LocatorHandler<T>,LocatorStatusHandler
- Direct Known Subclasses:
AbstractLocatorAndInvocationHandler
Abstract proxy handler supporting lazy loading and hooks on
WebElement.
Contains the locator handling related logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HookChainBuilderprotected List<HookDefinition<?>>protected List<FluentHook>protected final org.openqa.selenium.support.pagefactory.ElementLocatorprotected Tprotected T -
Constructor Summary
ConstructorsConstructorDescriptionAbstractLocatorHandler(org.openqa.selenium.support.pagefactory.ElementLocator locator) Creates a new locator handler. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddListener(ProxyElementListener listener) Add a listener for this locator handler.protected voidfireProxyElementFound(T result) Fire proxy element found event.protected voidFire proxy element search event.protected abstract org.openqa.selenium.WebElementGet the underlying element.org.openqa.selenium.support.pagefactory.ElementLocatorRetrieve the element locator used by this proxy, with hooks applied.protected StringGet string representation of not already found element.org.openqa.selenium.support.pagefactory.ElementLocatorRetrieve the element locator used by this proxy, without any hook applied.Get the actual result of the locator, if result is not defined and not stale.abstract TGet the actual result of the locator.protected abstract booleanisStale()Get the stale status of the element.booleanloaded()Check if this handler has loaded it's result.booleanpresent()Check if the result is present.proxyToString(String elementToString) Get string representation of the proxybooleanremoveListener(ProxyElementListener listener) Removes a proxy element listener.voidreset()Reset the loaded data.protected abstract List<org.openqa.selenium.WebElement>resultToList(T result) Convert result to a list of selenium element.voidsetHooks(HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions) Apply this hook list.voidSet the proxy using this handler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluentlenium.core.proxy.LocatorHandler
getInvocationTarget, getMessageContext, noSuchElement, now
-
Field Details
-
locator
protected final org.openqa.selenium.support.pagefactory.ElementLocator locator -
hookChainBuilder
-
hookDefinitions
-
hooks
-
proxy
-
result
-
-
Constructor Details
-
AbstractLocatorHandler
public AbstractLocatorHandler(org.openqa.selenium.support.pagefactory.ElementLocator locator) Creates a new locator handler.- Parameters:
locator- selenium element locator
-
-
Method Details
-
addListener
Description copied from interface:LocatorHandlerAdd a listener for this locator handler.- Specified by:
addListenerin 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
Description copied from interface:LocatorHandlerRemoves a proxy element listener.- Specified by:
removeListenerin interfaceLocatorHandler<T>- Parameters:
listener- listener to remove- Returns:
- true if the listener was removed, false otherwise
-
getLocatorResult
Get the actual result of the locator, if result is not defined and not stale.It also raise events.
- Specified by:
getLocatorResultin interfaceLocatorHandler<T>- Returns:
- result of the locator
-
setHooks
Description copied from interface:LocatorHandlerApply this hook list.- Specified by:
setHooksin interfaceLocatorHandler<T>- Parameters:
hookChainBuilder- hook chain builderhookDefinitions- hook definitions
-
getLocator
public org.openqa.selenium.support.pagefactory.ElementLocator getLocator()Description copied from interface:LocatorHandlerRetrieve the element locator used by this proxy, without any hook applied.- Specified by:
getLocatorin interfaceLocatorHandler<T>- Returns:
- element locator
-
getHookLocator
public org.openqa.selenium.support.pagefactory.ElementLocator getHookLocator()Description copied from interface:LocatorHandlerRetrieve the element locator used by this proxy, with hooks applied.- Specified by:
getHookLocatorin interfaceLocatorHandler<T>- Returns:
- element locator wrapped with hooks
-
loaded
public boolean loaded()Description copied from interface:LocatorStatusHandlerCheck if this handler has loaded it's result.- Specified by:
loadedin interfaceLocatorStatusHandler- Returns:
- true if the result is loaded, false otherwise
-
present
public boolean present()Description copied from interface:LocatorStatusHandlerCheck if the result is present.- Specified by:
presentin interfaceLocatorStatusHandler- Returns:
- true if result is present, false otherwise
-
reset
public void reset()Description copied from interface:LocatorStatusHandlerReset the loaded data.- Specified by:
resetin interfaceLocatorStatusHandler
-
setProxy
Set the proxy using this handler.- Parameters:
proxy- proxy using this handler
-
fireProxyElementSearch
protected void fireProxyElementSearch()Fire proxy element search event. -
fireProxyElementFound
Fire proxy element found event.- Parameters:
result- found element
-
getLocatorResultImpl
Get the actual result of the locator.- Returns:
- result of the locator
-
resultToList
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
Get string representation of not already found element.- Returns:
- string representation of not already found element
-
proxyToString
Get string representation of the proxy- Parameters:
elementToString- string representation of the underlying element- Returns:
- string representation of the proxy
-