Package io.fluentlenium.core.proxy
Class LocatorProxies
java.lang.Object
io.fluentlenium.core.proxy.LocatorProxies
Utility class to create proxies of WebElement, Component, FluentList and List of
Components based on their locators.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addProxyListener
(Object proxy, ProxyElementListener listener) Add a proxy listener for this proxy.static org.openqa.selenium.WebElement
createWebElement
(Supplier<org.openqa.selenium.WebElement> elementSupplier) Create a WebElement proxy from an element supplier.static org.openqa.selenium.WebElement
createWebElement
(org.openqa.selenium.support.pagefactory.ElementLocator locator) Create a WebElement proxy from an element locator.static org.openqa.selenium.WebElement
createWebElement
(org.openqa.selenium.WebElement element) Create a WebElement proxy from an existing element.static List<org.openqa.selenium.WebElement>
createWebElementList
(Supplier<List<org.openqa.selenium.WebElement>> elementsSupplier) Create a list of WebElement proxies from a supplier of element list.static List<org.openqa.selenium.WebElement>
createWebElementList
(List<org.openqa.selenium.WebElement> elements) Create a list of WebElement proxies from an existing element list.static List<org.openqa.selenium.WebElement>
createWebElementList
(org.openqa.selenium.support.pagefactory.ElementLocator locator) Create a list of WebElement proxies from a locator of element list.static org.openqa.selenium.WebElement
Creates a proxy element matching the first element of the list.static LocatorHandler
getLocatorHandler
(Object proxy) Get the proxy locator handler.static <T> T
getLocatorResult
(T proxy) Get the underlying result of a proxy, through locator handler.static String
getMessageContext
(Object proxy) Get the message context of given proxy.static org.openqa.selenium.WebElement
Creates a proxy element matching the n-th element of the list.static org.openqa.selenium.WebElement
Creates a proxy element matching the last element of the list.static boolean
Check if this proxy has loaded it's result.static org.openqa.selenium.NoSuchElementException
noSuchElement
(Object proxy) Build a NoSuchElementException using message provided by proxy.static void
If result is not loaded, load result immediatly.static boolean
Check if the proxy element is present.static boolean
removeProxyListener
(Object proxy, ProxyElementListener listener) Removes a proxy element listener.static void
Reset the proxy locator handler.static void
setHooks
(Object proxy, HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions) Apply this hook list.
-
Method Details
-
noSuchElement
Build a NoSuchElementException using message provided by proxy.- Parameters:
proxy
- proxy- Returns:
- NoSuchElementException No such element exception
-
getMessageContext
Get the message context of given proxy.- Parameters:
proxy
- proxy- Returns:
- message context
-
getLocatorHandler
Get the proxy locator handler.- Parameters:
proxy
- proxy object- Returns:
- locator handler, or null if not found
-
getLocatorResult
public static <T> T getLocatorResult(T proxy) Get the underlying result of a proxy, through locator handler.- Type Parameters:
T
- type of the result- Parameters:
proxy
- proxy object- Returns:
- result
- See Also:
-
reset
Reset the proxy locator handler.- Parameters:
proxy
- proxy object- See Also:
-
present
Check if the proxy element is present.- Parameters:
proxy
- proxy object- Returns:
- true if result is present, false otherwise
- See Also:
-
now
If result is not loaded, load result immediatly. If it's already loaded, it has no effect.- Parameters:
proxy
- proxy object- See Also:
-
loaded
Check if this proxy has loaded it's result.- Parameters:
proxy
- proxy object- Returns:
- true if the result is loaded, false otherwise
-
addProxyListener
Add a proxy listener for this proxy.- Parameters:
proxy
- proxy objectlistener
- listener to add, which will be notified when result is searched and found- Returns:
- true if the listener was added, false otherwise
-
removeProxyListener
Removes a proxy element listener.- Parameters:
proxy
- proxy objectlistener
- listener to remove- Returns:
- true if the listener was removed, false otherwise
-
createWebElement
public static org.openqa.selenium.WebElement createWebElement(org.openqa.selenium.WebElement element) Create a WebElement proxy from an existing element.- Parameters:
element
- existing element- Returns:
- proxy
-
createWebElement
public static org.openqa.selenium.WebElement createWebElement(Supplier<org.openqa.selenium.WebElement> elementSupplier) Create a WebElement proxy from an element supplier.- Parameters:
elementSupplier
- element supplier- Returns:
- proxy
-
createWebElement
public static org.openqa.selenium.WebElement createWebElement(org.openqa.selenium.support.pagefactory.ElementLocator locator) Create a WebElement proxy from an element locator.- Parameters:
locator
- element locator- Returns:
- proxy
-
createWebElementList
public static List<org.openqa.selenium.WebElement> createWebElementList(List<org.openqa.selenium.WebElement> elements) Create a list of WebElement proxies from an existing element list.- Parameters:
elements
- existing element list- Returns:
- proxy
-
createWebElementList
public static List<org.openqa.selenium.WebElement> createWebElementList(Supplier<List<org.openqa.selenium.WebElement>> elementsSupplier) Create a list of WebElement proxies from a supplier of element list.- Parameters:
elementsSupplier
- supplier of element list- Returns:
- proxy
-
createWebElementList
public static List<org.openqa.selenium.WebElement> createWebElementList(org.openqa.selenium.support.pagefactory.ElementLocator locator) Create a list of WebElement proxies from a locator of element list.- Parameters:
locator
- locator of element list- Returns:
- proxy
-
setHooks
public static void setHooks(Object proxy, HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions) Apply this hook list.- Parameters:
proxy
- proxy objecthookChainBuilder
- hook chain builderhookDefinitions
- hook definitions
-
first
Creates a proxy element matching the first element of the list.- Parameters:
proxy
- list of element- Returns:
- proxy element matching the first element
-
last
Creates a proxy element matching the last element of the list.- Parameters:
proxy
- list of element- Returns:
- proxy element matching the last element
-
index
public static org.openqa.selenium.WebElement index(List<org.openqa.selenium.WebElement> proxy, int index) Creates a proxy element matching the n-th element of the list.- Parameters:
proxy
- list of elementindex
- index to match- Returns:
- proxy element matching the n-th element
-