Package org.fluentlenium.core.domain
Class FluentWebElement
- java.lang.Object
-
- org.fluentlenium.core.domain.Component
-
- org.fluentlenium.core.domain.FluentWebElement
-
- All Implemented Interfaces:
FluentActions<FluentWebElement,FluentWebElement>
,FluentJavascriptActions
,AlertControl
,CapabilitiesControl
,ComponentInstantiator
,CssControl
,EventsControl
,HookControl<FluentWebElement>
,FluentInjectControl
,FluentLabel<FluentWebElement>
,NavigationControl
,FluentProxyState<FluentWebElement>
,JavascriptControl
,SearchControl<FluentWebElement>
,SeleniumDriverControl
,SnapshotControl
,org.openqa.selenium.internal.WrapsElement
,org.openqa.selenium.WrapsElement
public class FluentWebElement extends Component implements org.openqa.selenium.internal.WrapsElement, FluentActions<FluentWebElement,FluentWebElement>, FluentProxyState<FluentWebElement>, SearchControl<FluentWebElement>, HookControl<FluentWebElement>, FluentLabel<FluentWebElement>, NavigationControl, JavascriptControl, AlertControl, SnapshotControl, EventsControl, SeleniumDriverControl, CssControl, FluentInjectControl, CapabilitiesControl, ComponentInstantiator
Wraps a SeleniumWebElement
. It provides an enhanced API to control selenium element.
-
-
Field Summary
-
Fields inherited from class org.fluentlenium.core.domain.Component
control, instantiator, webElement
-
-
Constructor Summary
Constructors Constructor Description FluentWebElement(org.openqa.selenium.WebElement element, FluentControl control, ComponentInstantiator instantiator)
Creates a new fluent web element.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Alert
alert()
Get an object to control the alert window.<T> T
as(java.lang.Class<T> componentClass)
Wrap all underlying elements in a component.<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> elements)
Create and register a new list of component from the given element iterable.<L extends java.util.List<T>,T>
LasComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, java.util.List<org.openqa.selenium.WebElement> elements)
Create and register a new list of component from the given element iterable.<L extends java.util.List<T>,T>
LasComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, org.openqa.selenium.WebElement... elements)
Create and register a new list of component from the given element iterable.<T> ComponentList
asComponentList(java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Create and register a new list of component from the given element iterable.<T> ComponentList<T>
asComponentList(java.lang.Class<T> componentClass, java.util.List<org.openqa.selenium.WebElement> elements)
Create and register a new list of component from the given element iterable.<T> ComponentList<T>
asComponentList(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement... elements)
Create and register a new list of component from the given element iterable.<T extends FluentWebElement>
FluentList<T>asFluentList(java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>asFluentList(java.lang.Class<T> componentClass, java.util.List<org.openqa.selenium.WebElement> elements)
Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>asFluentList(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement... elements)
Create and register a new fluent list.FluentList<FluentWebElement>
asFluentList(java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Create and register a new fluent list from the argument collection of WebElements.FluentList<FluentWebElement>
asFluentList(java.util.List<org.openqa.selenium.WebElement> elements)
Create and register a new fluent list from the argument list of WebElements.FluentList<FluentWebElement>
asFluentList(org.openqa.selenium.WebElement... elements)
Create and register a new fluent list from the argument WebElements.FluentList<FluentWebElement>
asList()
Converts this element as a single element list.java.lang.String
attribute(java.lang.String name)
return any value of custom attribute (generated=true will return "true" if attribute("generated") is called.FluentWaitElement
await()
Build a wait object to wait for a condition of this element.Dom
axes()
Deprecated.Usedom()
instead.boolean
canTakeScreenShot()
Check if underlyingWebDriver
can take screenshot.org.openqa.selenium.Capabilities
capabilities()
Get the actual capabilities of the underlying Selenium WebDriver.FluentWebElement
clear()
Clear the elementFluentWebElement
clearReactInput()
Clear React input using Backspace onlyFluentWebElement
click()
Perform a click.boolean
clickable()
Check that this element is visible and enabled such that you can click it.FluentConditions
conditions()
Get a conditions object used to verify condition on this element.FluentWebElement
contextClick()
Perform a context click.CssSupport
css()
Features related to CSS loaded in the active page.java.lang.String
cssValue(java.lang.String propertyName)
Get the value of a given CSS property.boolean
displayed()
return true if the element is displayed, other way return falseDom
dom()
XPath Axes accessor (parent, ancestors, preceding, following, ...).FluentWebElement
doubleClick()
Perform a double click.FluentWebElement
el(org.openqa.selenium.WebElement rawElement)
Wrap existing raw selenium element into an element.boolean
enabled()
return true if the element is enabled, other way return falseEventsRegistry
events()
Retrieves an event registry to register event listeners.FluentJavascript
executeAsyncScript(java.lang.String script, java.lang.Object... args)
Execute a script, asynchronously.FluentJavascript
executeScript(java.lang.String script, java.lang.Object... args)
Execute a script, synchronously.Fill<FluentWebElement>
fill()
Construct a Fill Builder in order to allow easy fill of visible input fields.FillSelect<FluentWebElement>
fillSelect()
Construct a Fill Select Builder in order to allow easy fill of visible input fields.FluentList<FluentWebElement>
find(java.lang.String selector, SearchFilter... filters)
Find list of elements with CSS selector and filters.FluentList<FluentWebElement>
find(java.util.List<org.openqa.selenium.WebElement> rawElements)
Wrap raw selenium elements into a list of elements.FluentList<FluentWebElement>
find(SearchFilter... filters)
Find list of elements with filters.FluentList<FluentWebElement>
find(org.openqa.selenium.By locator, SearchFilter... filters)
Find list of elements with Selenium locator and filters.FluentWebElement
frame()
Select a frame using this element.io.appium.java_client.AppiumDriver<?>
getAppiumDriver()
Get the actual underlying AppiumDriver.org.openqa.selenium.Cookie
getCookie(java.lang.String name)
return the corresponding cookie given a namejava.util.Set<org.openqa.selenium.Cookie>
getCookies()
return the cookies as a setorg.openqa.selenium.WebDriver
getDriver()
Get the actual underlying Selenium WebDriver.org.openqa.selenium.WebElement
getElement()
return the webElementFluentLabel<FluentWebElement>
getLabel()
org.openqa.selenium.WebElement
getWrappedElement()
void
goTo(java.lang.String url)
Open the url page<P extends FluentPage>
PgoTo(P page)
Open the page, using the url defined in the pagevoid
goToInNewTab(java.lang.String url)
Open the url page in a new tabFluentWebElement
hoverOver()
Hovers the mouse over the current element.java.lang.String
html()
Get the HTML of a the elementjava.lang.String
id()
return the id of the elementsContainerContext
inject(java.lang.Object container)
Inject object with FluentLenium resources.ContainerContext
injectComponent(java.lang.Object componentContainer, java.lang.Object parentContainer, org.openqa.selenium.SearchContext context)
Inject object with FluentLenium resources, using given search context and parent container.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.KeyboardElementActions
keyboard()
Execute keyboard actions on the elementboolean
loaded()
Check if the element is loaded.FluentWebElement
modifyAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Modifies element attributesMouseElementActions
mouse()
Execute mouse actions on the elementjava.lang.String
name()
return the name of the element<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)
Create and register an empty list of component.<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.<L extends java.util.List<T>,T>
LnewComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, T... componentsList)
Create and register a new list of component from the given component list.<T> ComponentList<T>
newComponentList(java.lang.Class<T> componentClass)
Create and register an empty list of component.<T> ComponentList<T>
newComponentList(java.lang.Class<T> componentClass, java.util.List<T> componentsList)
Create and register a new list of component from the given component list.<T> ComponentList<T>
newComponentList(java.lang.Class<T> componentClass, T... componentsList)
Create and register a new list of component from the given component list.FluentWebElement
newFluent(org.openqa.selenium.WebElement element)
Create and register a newFluentWebElement
from the givenWebElement
.FluentList<FluentWebElement>
newFluentList()
Create and register an empty fluent list.<T extends FluentWebElement>
FluentList<T>newFluentList(java.lang.Class<T> componentClass)
Create and register an empty fluent list of the provided type.<T extends FluentWebElement>
FluentList<T>newFluentList(java.lang.Class<T> componentClass, java.util.List<T> elements)
Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>newFluentList(java.lang.Class<T> componentClass, T... elements)
Create and register a new fluent list.FluentList<FluentWebElement>
newFluentList(java.util.List<FluentWebElement> elements)
Create and register a new fluent list from the argument list of FluentWebElements.FluentList<FluentWebElement>
newFluentList(FluentWebElement... elements)
Create and register a new fluent list from the argument FluentWebElements.<T> T
newInstance(java.lang.Class<T> cls)
Creates a new instance of a class inject it.FluentWebElement
noHook()
Disable all hooks from actual element.FluentWebElement
noHook(java.lang.Class<? extends FluentHook>... hooks)
Disable given hook from actual element.<R> R
noHook(java.lang.Class<? extends FluentHook> hook, java.util.function.Function<FluentWebElement,R> function)
Invoke a function with no hook.<R> R
noHook(java.util.function.Function<FluentWebElement,R> function)
Invoke a function with no hook.FluentWebElement
noHookInstance()
Creates a new element locator instance with all hooks disabled.FluentWebElement
noHookInstance(java.lang.Class<? extends FluentHook>... hooks)
Creates a new element locator instance with given hook disabled.FluentWebElement
now()
Search for the element now, actually performing the search on theWebDriver
.FluentWebElement
now(boolean force)
Search for the element now, actually performing the search on theWebDriver
.java.util.Optional<FluentWebElement>
optional()
Builds an optional.java.lang.String
pageSource()
Return the source of the pageboolean
present()
Check if the element is present in the DOM.FluentWebElement
reset()
Reset the element.FluentWebElement
restoreHooks()
Retore hooks that were defined initially.FluentWebElement
scrollIntoView()
Scrolls the current element into the visible area of the browser window.FluentWebElement
scrollIntoView(boolean alignWithTop)
Scrolls the current element into the visible area of the browser window.FluentWebElement
scrollToCenter()
Scrolls center of the current element into the visible area of the browser window, respecting window size.boolean
selected()
return true if the element is selected, other way falseorg.openqa.selenium.Dimension
size()
return the size of the elementboolean
stale()
Check that this element is no longer attached to the DOM.FluentWebElement
submit()
Submit the elementvoid
switchTo()
Switch to the default elementvoid
switchTo(FluentList<? extends FluentWebElement> elements)
Switch to the first selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)void
switchTo(FluentWebElement element)
Switch to the selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)void
switchToDefault()
Switch to the default elementjava.lang.String
tagName()
return the tag namevoid
takeHtmlDump()
Take a html dump of the browser DOM.void
takeHtmlDump(java.lang.String fileName)
Take a html dump of the browser DOM into a file given by the fileName param.void
takeScreenshot()
Take a snapshot of the browser.void
takeScreenshot(java.lang.String fileName)
Take a snapshot of the browser into a file given by the fileName param.java.lang.String
text()
return the visible text of the elementjava.lang.String
textContent()
return the text content of the element (even invisible through textContent attribute)java.lang.String
toString()
java.lang.String
url()
Return the url of the page.java.lang.String
value()
return the value of the elementsFluentWebElement
waitAndClick()
Helper method that: a) waits at most 5 seconds for element b) scrolls centrally into it c) clicks on itFluentWebElement
waitAndClick(java.time.Duration duration)
Helper method that: a) waits for element b) scrolls centrally into it c) clicks on itWindowAction
window()
Exposes methods on browser window<O,H extends FluentHook<O>>
FluentWebElementwithHook(java.lang.Class<H> hook)
Enable a hook with default options.<O,H extends FluentHook<O>>
FluentWebElementwithHook(java.lang.Class<H> hook, O options)
Enable a hook with given options.FluentWebElement
withLabel(java.lang.String label)
Apply a label that will be displayed as the representation of this object for error message.FluentWebElement
withLabelHint(java.lang.String... labelHint)
Add a label hint that will be appended to the representation of this object for error message.FluentWebElement
write(java.lang.String... text)
Set the text element
-
-
-
Constructor Detail
-
FluentWebElement
public FluentWebElement(org.openqa.selenium.WebElement element, FluentControl control, ComponentInstantiator instantiator)
Creates a new fluent web element.- Parameters:
element
- underlying elementcontrol
- control interfaceinstantiator
- component instantiator
-
-
Method Detail
-
getLabel
public FluentLabel<FluentWebElement> getLabel()
-
executeScript
public FluentJavascript executeScript(java.lang.String script, java.lang.Object... args)
Description copied from interface:JavascriptControl
Execute a script, synchronously.- Specified by:
executeScript
in interfaceJavascriptControl
- Parameters:
script
- script source to executeargs
- script arguments- Returns:
- an object wrapping the result
-
executeAsyncScript
public FluentJavascript executeAsyncScript(java.lang.String script, java.lang.Object... args)
Description copied from interface:JavascriptControl
Execute a script, asynchronously.- Specified by:
executeAsyncScript
in interfaceJavascriptControl
- Parameters:
script
- script source to executeargs
- script arguments- Returns:
- an object wrapping the result
-
alert
public Alert alert()
Description copied from interface:AlertControl
Get an object to control the alert window.- Specified by:
alert
in interfaceAlertControl
- Returns:
- an alert object
-
takeHtmlDump
public void takeHtmlDump()
Description copied from interface:SnapshotControl
Take a html dump of the browser DOM. By default the file will be a html named by the current timestamp.- Specified by:
takeHtmlDump
in interfaceSnapshotControl
-
takeHtmlDump
public void takeHtmlDump(java.lang.String fileName)
Description copied from interface:SnapshotControl
Take a html dump of the browser DOM into a file given by the fileName param.- Specified by:
takeHtmlDump
in interfaceSnapshotControl
- Parameters:
fileName
- file name for html dump
-
canTakeScreenShot
public boolean canTakeScreenShot()
Description copied from interface:SnapshotControl
Check if underlyingWebDriver
can take screenshot.- Specified by:
canTakeScreenShot
in interfaceSnapshotControl
- Returns:
- true if screenshot can be taken, false otherwise
-
takeScreenshot
public void takeScreenshot()
Description copied from interface:SnapshotControl
Take a snapshot of the browser. By default the file will be a png named by the current timestamp.- Specified by:
takeScreenshot
in interfaceSnapshotControl
-
takeScreenshot
public void takeScreenshot(java.lang.String fileName)
Description copied from interface:SnapshotControl
Take a snapshot of the browser into a file given by the fileName param.- Specified by:
takeScreenshot
in interfaceSnapshotControl
- Parameters:
fileName
- file name for screenshot
-
events
public EventsRegistry events()
Description copied from interface:EventsControl
Retrieves an event registry to register event listeners.- Specified by:
events
in interfaceEventsControl
- Returns:
- the event registry.
-
goTo
public <P extends FluentPage> P goTo(P page)
Description copied from interface:NavigationControl
Open the page, using the url defined in the page- Specified by:
goTo
in interfaceNavigationControl
- Type Parameters:
P
- Type of FluentPage- Parameters:
page
- page to open- Returns:
- Opened page.
- See Also:
FluentPage.getUrl()
-
goTo
public void goTo(java.lang.String url)
Description copied from interface:NavigationControl
Open the url page- Specified by:
goTo
in interfaceNavigationControl
- Parameters:
url
- page URL to visit
-
goToInNewTab
public void goToInNewTab(java.lang.String url)
Description copied from interface:NavigationControl
Open the url page in a new tab- Specified by:
goToInNewTab
in interfaceNavigationControl
- Parameters:
url
- the url of the page
-
switchTo
public void switchTo(FluentList<? extends FluentWebElement> elements)
Description copied from interface:NavigationControl
Switch to the first selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)- Specified by:
switchTo
in interfaceNavigationControl
- Parameters:
elements
- fluent list of fluent web elements
-
switchTo
public void switchTo(FluentWebElement element)
Description copied from interface:NavigationControl
Switch to the selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)- Specified by:
switchTo
in interfaceNavigationControl
- Parameters:
element
- fluent web element to switch to
-
switchTo
public void switchTo()
Description copied from interface:NavigationControl
Switch to the default element- Specified by:
switchTo
in interfaceNavigationControl
-
switchToDefault
public void switchToDefault()
Description copied from interface:NavigationControl
Switch to the default element- Specified by:
switchToDefault
in interfaceNavigationControl
-
pageSource
public java.lang.String pageSource()
Description copied from interface:NavigationControl
Return the source of the page- Specified by:
pageSource
in interfaceNavigationControl
- Returns:
- source of the page under test
-
window
public WindowAction window()
Description copied from interface:NavigationControl
Exposes methods on browser window- Specified by:
window
in interfaceNavigationControl
- Returns:
- Window actions
-
getCookies
public java.util.Set<org.openqa.selenium.Cookie> getCookies()
Description copied from interface:NavigationControl
return the cookies as a set- Specified by:
getCookies
in interfaceNavigationControl
- Returns:
- set of cookies
-
getCookie
public org.openqa.selenium.Cookie getCookie(java.lang.String name)
Description copied from interface:NavigationControl
return the corresponding cookie given a name- Specified by:
getCookie
in interfaceNavigationControl
- Parameters:
name
- cookie name- Returns:
- cookie selected by name
-
url
public java.lang.String url()
Description copied from interface:NavigationControl
Return the url of the page. If a base url is provided, the current url will be relative to that base url.- Specified by:
url
in interfaceNavigationControl
- Returns:
- current URL
-
getDriver
public org.openqa.selenium.WebDriver getDriver()
Description copied from interface:SeleniumDriverControl
Get the actual underlying Selenium WebDriver.To customize the WebDriver, you should configure
FluentControl.getWebDriver()
or overrideIFluentAdapter.newWebDriver()
.This method can't be overridden to customize the WebDriver.
- Specified by:
getDriver
in interfaceSeleniumDriverControl
- Returns:
- The actual underlying Selenium WebDriver
-
getAppiumDriver
public io.appium.java_client.AppiumDriver<?> getAppiumDriver()
Description copied from interface:SeleniumDriverControl
Get the actual underlying AppiumDriver.To customize the WebDriver, you should configure
FluentControl.getWebDriver()
or overrideIFluentAdapter.newWebDriver()
.This method can't be overridden to customize the AppiumDriver.
- Specified by:
getAppiumDriver
in interfaceSeleniumDriverControl
- Returns:
- The actual underlying AppiumDriver
-
css
public CssSupport css()
Description copied from interface:CssControl
Features related to CSS loaded in the active page.- Specified by:
css
in interfaceCssControl
- Returns:
- a CssSupport instance
-
inject
public ContainerContext inject(java.lang.Object container)
Description copied from interface:FluentInjectControl
Inject object with FluentLenium resources.- Specified by:
inject
in interfaceFluentInjectControl
- Parameters:
container
- container to inject with FluentLenium resources- Returns:
- The container context related to the injected container
-
injectComponent
public ContainerContext injectComponent(java.lang.Object componentContainer, java.lang.Object parentContainer, org.openqa.selenium.SearchContext context)
Description copied from interface:FluentInjectControl
Inject object with FluentLenium resources, using given search context and parent container.- Specified by:
injectComponent
in interfaceFluentInjectControl
- Parameters:
componentContainer
- container to inject with FluentLenium resourcesparentContainer
- parent containercontext
- search context to use for injection- Returns:
- The container context related to the injected container
-
newInstance
public <T> T newInstance(java.lang.Class<T> cls)
Description copied from interface:FluentInjectControl
Creates a new instance of a class inject it.- Specified by:
newInstance
in interfaceFluentInjectControl
- Type Parameters:
T
- type of the object- Parameters:
cls
- class of the object to create- Returns:
- new container instance
- See Also:
FluentInjectControl.inject(Object)
-
newFluent
public FluentWebElement newFluent(org.openqa.selenium.WebElement element)
Description copied from interface:ComponentInstantiator
Create and register a newFluentWebElement
from the givenWebElement
.- Specified by:
newFluent
in interfaceComponentInstantiator
- Parameters:
element
- wrapped element- Returns:
- new instance of the component
-
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
-
newFluentList
public FluentList<FluentWebElement> newFluentList()
Description copied from interface:ComponentInstantiator
Create and register an empty fluent list.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Returns:
- new list of fluent web element
-
newFluentList
public FluentList<FluentWebElement> newFluentList(FluentWebElement... elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list from the argument FluentWebElements.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Parameters:
elements
- list of elements- Returns:
- new list of fluent web element
-
newFluentList
public FluentList<FluentWebElement> newFluentList(java.util.List<FluentWebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list from the argument list of FluentWebElements.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Parameters:
elements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public FluentList<FluentWebElement> asFluentList(org.openqa.selenium.WebElement... elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list from the argument WebElements.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Parameters:
elements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public FluentList<FluentWebElement> asFluentList(java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list from the argument collection of WebElements.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Parameters:
elements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public FluentList<FluentWebElement> asFluentList(java.util.List<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list from the argument list of WebElements.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Parameters:
elements
- list of elements- Returns:
- new list of fluent web element
-
newFluentList
public <T extends FluentWebElement> FluentList<T> newFluentList(java.lang.Class<T> componentClass)
Description copied from interface:ComponentInstantiator
Create and register an empty fluent list of the provided type.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the component- Returns:
- new list of fluent web element
-
newFluentList
public <T extends FluentWebElement> FluentList<T> newFluentList(java.lang.Class<T> componentClass, T... elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the componentelements
- list of elements- Returns:
- new list of fluent web element
-
newFluentList
public <T extends FluentWebElement> FluentList<T> newFluentList(java.lang.Class<T> componentClass, java.util.List<T> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list.- Specified by:
newFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the componentelements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement... elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the componentelements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the componentelements
- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(java.lang.Class<T> componentClass, java.util.List<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new fluent list.- Specified by:
asFluentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- class of the componentelements
- list of elements- Returns:
- new list of fluent web element
-
newComponentList
public <T> ComponentList<T> newComponentList(java.lang.Class<T> componentClass)
Description copied from interface:ComponentInstantiator
Create and register an empty list of component.- Specified by:
newComponentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- type of the component- Returns:
- new list of components
-
asComponentList
public <T> ComponentList<T> asComponentList(java.lang.Class<T> componentClass, org.openqa.selenium.WebElement... elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- type of the componentelements
- elements- Returns:
- new list of components
-
asComponentList
public <T> ComponentList asComponentList(java.lang.Class<T> componentClass, java.lang.Iterable<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- type of the componentelements
- elements- Returns:
- new list of components
-
asComponentList
public <T> ComponentList<T> asComponentList(java.lang.Class<T> componentClass, java.util.List<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
T
- type of the component- Parameters:
componentClass
- type of the componentelements
- elements- Returns:
- new list of components
-
newComponentList
public <T> ComponentList<T> newComponentList(java.lang.Class<T> componentClass, 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:
T
- type of the component- Parameters:
componentClass
- type of the componentcomponentsList
- components list- Returns:
- new list of components
-
newComponentList
public <T> ComponentList<T> newComponentList(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:
T
- type of the component- Parameters:
componentClass
- type of the componentcomponentsList
- components list- Returns:
- new list of components
-
newComponentList
public <L extends java.util.List<T>,T> L newComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass)
Description copied from interface:ComponentInstantiator
Create and register an empty list of component.- 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 component- 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, org.openqa.selenium.WebElement... elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
L
- type of the listT
- type of the component- Parameters:
listClass
- type of the listcomponentClass
- type of the componentelements
- elements- 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> elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
L
- type of the listT
- type of the component- Parameters:
listClass
- type of the listcomponentClass
- type of the componentelements
- elements- 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.util.List<org.openqa.selenium.WebElement> elements)
Description copied from interface:ComponentInstantiator
Create and register a new list of component from the given element iterable.- Specified by:
asComponentList
in interfaceComponentInstantiator
- Type Parameters:
L
- type of the listT
- type of the component- Parameters:
listClass
- type of the listcomponentClass
- type of the componentelements
- elements- Returns:
- new list of components
-
newComponentList
public <L extends java.util.List<T>,T> L newComponentList(java.lang.Class<L> listClass, java.lang.Class<T> componentClass, 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
-
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
-
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
-
capabilities
public org.openqa.selenium.Capabilities capabilities()
Description copied from interface:CapabilitiesControl
Get the actual capabilities of the underlying Selenium WebDriver.- Specified by:
capabilities
in interfaceCapabilitiesControl
- Returns:
- actual capabilities.
- See Also:
HasCapabilities.getCapabilities()
-
click
public FluentWebElement click()
Description copied from interface:FluentActions
Perform a click.- Specified by:
click
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- this object reference to chain methods calls
- See Also:
WebElement.click()
-
doubleClick
public FluentWebElement doubleClick()
Description copied from interface:FluentActions
Perform a double click.- Specified by:
doubleClick
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- this object reference to chain methods calls
-
contextClick
public FluentWebElement contextClick()
Description copied from interface:FluentActions
Perform a context click.- Specified by:
contextClick
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- this object reference to chain methods calls
-
waitAndClick
public FluentWebElement 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<FluentWebElement,FluentWebElement>
- Returns:
- this object reference to chain methods calls
-
waitAndClick
public FluentWebElement waitAndClick(java.time.Duration duration)
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<FluentWebElement,FluentWebElement>
- Parameters:
duration
- - enabled to override default 5 seconds of waiting- Returns:
- this object reference to chain methods calls
-
hoverOver
public FluentWebElement hoverOver()
Description copied from interface:FluentActions
Hovers the mouse over the current element.By default, this is a convenience method for calling
element.mouse().moveToElement()
.- Specified by:
hoverOver
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- the current element
-
present
public boolean present()
Description copied from interface:FluentProxyState
Check if the element is present in the DOM.- Specified by:
present
in interfaceFluentProxyState<FluentWebElement>
- Returns:
- true if the element is present, false otherwise
-
now
public FluentWebElement 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<FluentWebElement>
- Returns:
- this object reference to chain calls.
-
now
public FluentWebElement now(boolean force)
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<FluentWebElement>
- Parameters:
force
- force the search even if element is already loaded- Returns:
- this object reference to chain calls.
-
reset
public FluentWebElement 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<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<FluentWebElement>
- Returns:
- true if the element is loaded, false otherwise
-
axes
@Deprecated public Dom axes()
Deprecated.Usedom()
instead.XPath Axes accessor (parent, ancestors, preceding, following, ...).- Returns:
- object to perform XPath Axes transformations.
-
dom
public Dom dom()
XPath Axes accessor (parent, ancestors, preceding, following, ...).- Returns:
- object to perform XPath Axes transformations.
-
conditions
public FluentConditions conditions()
Get a conditions object used to verify condition on this element.- Returns:
- conditions object
-
await
public FluentWaitElement await()
Build a wait object to wait for a condition of this element.- Returns:
- a wait object
-
mouse
public MouseElementActions mouse()
Execute mouse actions on the element- Returns:
- mouse actions object
-
keyboard
public KeyboardElementActions keyboard()
Execute keyboard actions on the element- Returns:
- keyboard actions object
-
as
public <T> T as(java.lang.Class<T> componentClass)
Wrap all underlying elements in a component.- Type Parameters:
T
- type of component- Parameters:
componentClass
- component class- Returns:
- element as component.
-
clear
public FluentWebElement clear()
Clear the element- Returns:
- fluent web element
-
clearReactInput
public FluentWebElement clearReactInput()
Clear React input using Backspace only- Returns:
- fluent web element
-
submit
public FluentWebElement submit()
Submit the element- Specified by:
submit
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- fluent web element
- See Also:
WebElement.submit()
-
write
public FluentWebElement write(java.lang.String... text)
Set the text element- Specified by:
write
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Parameters:
text
- value to set- Returns:
- fluent web element
- See Also:
WebElement.sendKeys(CharSequence...)
-
name
public java.lang.String name()
return the name of the element- Returns:
- name of the element
-
attribute
public java.lang.String attribute(java.lang.String name)
return any value of custom attribute (generated=true will return "true" if attribute("generated") is called.- Parameters:
name
- custom attribute name- Returns:
- name value
- See Also:
WebElement.getAttribute(String)
-
cssValue
public java.lang.String cssValue(java.lang.String propertyName)
Get the value of a given CSS property.- Parameters:
propertyName
- the css property name of the element- Returns:
- The current, computed value of the property.
- See Also:
WebElement.getCssValue(String)
-
id
public java.lang.String id()
return the id of the elements- Returns:
- id of element
-
text
public java.lang.String text()
return the visible text of the element- Returns:
- text of element
- See Also:
WebElement.getText()
-
textContent
public java.lang.String textContent()
return the text content of the element (even invisible through textContent attribute)- Returns:
- text content of element
-
value
public java.lang.String value()
return the value of the elements- Returns:
- value of attribute
-
displayed
public boolean displayed()
return true if the element is displayed, other way return false- Returns:
- boolean value of displayed check
- See Also:
WebElement.isDisplayed()
-
enabled
public boolean enabled()
return true if the element is enabled, other way return false- Returns:
- boolean value of enabled check
- See Also:
WebElement.isEnabled()
-
selected
public boolean selected()
return true if the element is selected, other way false- Returns:
- boolean value of selected check
- See Also:
WebElement.isSelected()
-
clickable
public boolean clickable()
Check that this element is visible and enabled such that you can click it.- Returns:
- true if the element can be clicked, false otherwise.
-
stale
public boolean stale()
Check that this element is no longer attached to the DOM.- Returns:
- false is the element is still attached to the DOM, true otherwise.
-
tagName
public java.lang.String tagName()
return the tag name- Returns:
- string value of tag name
- See Also:
WebElement.getTagName()
-
getElement
public org.openqa.selenium.WebElement getElement()
return the webElement- Returns:
- web element
-
getWrappedElement
public org.openqa.selenium.WebElement getWrappedElement()
- Specified by:
getWrappedElement
in interfaceorg.openqa.selenium.WrapsElement
-
size
public org.openqa.selenium.Dimension size()
return the size of the element- Returns:
- dimension/size of element
- See Also:
WebElement.getSize()
-
asList
public FluentList<FluentWebElement> asList()
Converts this element as a single element list.- Returns:
- list of element
-
find
public FluentList<FluentWebElement> find(org.openqa.selenium.By locator, SearchFilter... filters)
Description copied from interface:SearchControl
Find list of elements with Selenium locator and filters.- Specified by:
find
in interfaceSearchControl<FluentWebElement>
- Parameters:
locator
- elements locatorfilters
- filters set- Returns:
- list of elements
-
find
public FluentList<FluentWebElement> find(java.lang.String selector, SearchFilter... filters)
Description copied from interface:SearchControl
Find list of elements with CSS selector and filters.- Specified by:
find
in interfaceSearchControl<FluentWebElement>
- Parameters:
selector
- CSS selectorfilters
- set of filters- Returns:
- list of element
-
find
public FluentList<FluentWebElement> find(SearchFilter... filters)
Description copied from interface:SearchControl
Find list of elements with filters.- Specified by:
find
in interfaceSearchControl<FluentWebElement>
- Parameters:
filters
- set of filters in the current context- Returns:
- list of elements
-
find
public FluentList<FluentWebElement> find(java.util.List<org.openqa.selenium.WebElement> rawElements)
Description copied from interface:SearchControl
Wrap raw selenium elements into a list of elements.- Specified by:
find
in interfaceSearchControl<FluentWebElement>
- Parameters:
rawElements
- raw selenium elements- Returns:
- list of element
-
el
public FluentWebElement el(org.openqa.selenium.WebElement rawElement)
Description copied from interface:SearchControl
Wrap existing raw selenium element into an element.- Specified by:
el
in interfaceSearchControl<FluentWebElement>
- Parameters:
rawElement
- raw selenium element- Returns:
- element
-
html
public java.lang.String html()
Get the HTML of a the element- Returns:
- the underlying html content
-
fill
public Fill<FluentWebElement> 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<FluentWebElement,FluentWebElement>
- Returns:
- Fill builder
-
fillSelect
public FillSelect<FluentWebElement> 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<FluentWebElement,FluentWebElement>
- Returns:
- Fill select builder
-
frame
public FluentWebElement frame()
Description copied from interface:FluentActions
Select a frame using this element.- Specified by:
frame
in interfaceFluentActions<FluentWebElement,FluentWebElement>
- Returns:
- this object reference to chain methods calls.
-
optional
public java.util.Optional<FluentWebElement> 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<FluentWebElement>
- Returns:
- An optional wrapping this.
- See Also:
FluentProxyState.present()
,FluentProxyState.now()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
noHook
public <R> R noHook(java.lang.Class<? extends FluentHook> hook, java.util.function.Function<FluentWebElement,R> function)
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<FluentWebElement>
- Type Parameters:
R
- return type- Parameters:
hook
- hook class to disablefunction
- function to invoke- Returns:
- return value of the given function
-
withHook
public <O,H extends FluentHook<O>> FluentWebElement withHook(java.lang.Class<H> hook, O options)
Description copied from interface:HookControl
Enable a hook with given options.- Specified by:
withHook
in interfaceHookControl<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
-
withHook
public <O,H extends FluentHook<O>> FluentWebElement withHook(java.lang.Class<H> hook)
Description copied from interface:HookControl
Enable a hook with default options.- Specified by:
withHook
in interfaceHookControl<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
public FluentWebElement noHook(java.lang.Class<? extends FluentHook>... hooks)
Description copied from interface:HookControl
Disable given hook from actual element.- Specified by:
noHook
in interfaceHookControl<FluentWebElement>
- Parameters:
hooks
- hook classes to disable- Returns:
- this object reference to chain calls
-
noHook
public <R> R noHook(java.util.function.Function<FluentWebElement,R> function)
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<FluentWebElement>
- Type Parameters:
R
- return type- Parameters:
function
- function to invoke- Returns:
- return value of the given function
-
noHookInstance
public FluentWebElement noHookInstance(java.lang.Class<? extends FluentHook>... hooks)
Description copied from interface:HookControl
Creates a new element locator instance with given hook disabled.- Specified by:
noHookInstance
in interfaceHookControl<FluentWebElement>
- Parameters:
hooks
- hook classes to disable- Returns:
- new element locator with hook disabled.
-
restoreHooks
public FluentWebElement restoreHooks()
Description copied from interface:HookControl
Retore hooks that were defined initially.- Specified by:
restoreHooks
in interfaceHookControl<FluentWebElement>
- Returns:
- this object reference to chain calls
-
noHookInstance
public FluentWebElement noHookInstance()
Description copied from interface:HookControl
Creates a new element locator instance with all hooks disabled.- Specified by:
noHookInstance
in interfaceHookControl<FluentWebElement>
- Returns:
- new element locator with hook disabled.
-
noHook
public FluentWebElement noHook()
Description copied from interface:HookControl
Disable all hooks from actual element.- Specified by:
noHook
in interfaceHookControl<FluentWebElement>
- Returns:
- this object reference to chain calls
-
scrollToCenter
public FluentWebElement scrollToCenter()
Description copied from interface:FluentJavascriptActions
Scrolls center of the current element into the visible area of the browser window, respecting window size.- Specified by:
scrollToCenter
in interfaceFluentJavascriptActions
- Returns:
- this object reference to chain methods calls
-
scrollIntoView
public FluentWebElement scrollIntoView()
Description copied from interface:FluentJavascriptActions
Scrolls the current element into the visible area of the browser window.- Specified by:
scrollIntoView
in interfaceFluentJavascriptActions
- Returns:
- this object reference to chain methods calls
- See Also:
- element.scrollIntoView
-
scrollIntoView
public FluentWebElement scrollIntoView(boolean alignWithTop)
Description copied from interface:FluentJavascriptActions
Scrolls the current element into the visible area of the browser window.- Specified by:
scrollIntoView
in interfaceFluentJavascriptActions
- 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:
- element.scrollIntoView
-
modifyAttribute
public FluentWebElement modifyAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Description copied from interface:FluentJavascriptActions
Modifies element attributes- Specified by:
modifyAttribute
in interfaceFluentJavascriptActions
- Parameters:
attributeName
- attribute to be changeattributeValue
- new attribute value- Returns:
- this object reference to chain methods calls
-
withLabelHint
public FluentWebElement withLabelHint(java.lang.String... labelHint)
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<FluentWebElement>
- Parameters:
labelHint
- label hints to add- Returns:
- reference to this object to chain calls
-
withLabel
public FluentWebElement withLabel(java.lang.String label)
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<FluentWebElement>
- Parameters:
label
- label to use- Returns:
- reference to this object to chain calls
-
-