Package io.fluentlenium.core
Class FluentDriver
java.lang.Object
io.fluentlenium.core.FluentControlImpl
io.fluentlenium.core.FluentDriver
- All Implemented Interfaces:
Configuration,ConfigurationMutator,ConfigurationProperties,InputControl,AlertControl,CapabilitiesControl,ComponentInstantiator,CssControl,EventsControl,FluentControl,FluentInjectControl,NavigationControl,PerformanceTimingControl,JavascriptControl,SearchControl<FluentWebElement>,SeleniumDriverControl,SnapshotControl,AwaitControl,ChromiumControl
Wrapper class for a
WebDriver instance which also offers shortcut and convenience methods,
as well as methods to work with mouse, keyboard and windows.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.fluentlenium.configuration.ConfigurationProperties
ConfigurationProperties.DriverLifecycle, ConfigurationProperties.TriggerMode -
Constructor Summary
ConstructorsConstructorDescriptionFluentDriver(org.openqa.selenium.WebDriver driver, Configuration configuration, FluentControl adapter) Wrap the driver into a Fluent driver. -
Method Summary
Modifier and TypeMethodDescriptionWrap raw selenium elements into a list of elements.alert()Get an object to control the alert window.<L extends List<T>,T>
LasComponentList(Class<L> listClass, Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Create and register a new list of component from the given element iterable.<L extends List<T>,T>
LasComponentList(Class<L> listClass, Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Create and register a new list of component from the given element iterable.<L extends List<T>,T>
LasComponentList(Class<L> listClass, Class<T> componentClass, org.openqa.selenium.WebElement... elements) Create and register a new list of component from the given element iterable.<T> ComponentListasComponentList(Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Create and register a new list of component from the given element iterable.<T> ComponentList<T>asComponentList(Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Create and register a new list of component from the given element iterable.<T> ComponentList<T>asComponentList(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(Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>asFluentList(Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>asFluentList(Class<T> componentClass, org.openqa.selenium.WebElement... elements) Create and register a new fluent list.asFluentList(Iterable<org.openqa.selenium.WebElement> elements) Create and register a new fluent list from the argument collection of WebElements.asFluentList(List<org.openqa.selenium.WebElement> elements) Create and register a new fluent list from the argument list of WebElements.asFluentList(org.openqa.selenium.WebElement... elements) Create and register a new fluent list from the argument WebElements.await()wait for an asynchronous callbooleanCheck if underlyingWebDrivercan take screenshot.org.openqa.selenium.CapabilitiesGet the actual capabilities of the underlying Selenium WebDriver.css()Features related to CSS loaded in the active page.el(org.openqa.selenium.WebElement rawElement) Wrap existing raw selenium element into an element.events()Retrieves an event registry to register event listeners.executeAsyncScript(String script, Object... args) Execute a script, asynchronously.executeScript(String script, Object... args) Execute a script, synchronously.find(SearchFilter... filters) Find list of elements with filters.find(String selector, SearchFilter... filters) Find list of elements with CSS selector and filters.Wrap raw selenium elements into a list of elements.find(org.openqa.selenium.By locator, SearchFilter... filters) Find list of elements with Selenium locator and filters.io.appium.java_client.AppiumDriverGet the actual underlying AppiumDriver.Features related to browser control under devtools protocol.protected ComponentsManagerReturns theComponentsManagerrequired for this class.Get the test adapter configuration.org.openqa.selenium.Cookiereturn the corresponding cookie given a nameSet<org.openqa.selenium.Cookie>return the cookies as a setorg.openqa.selenium.WebDriverGet the actual underlying Selenium WebDriver.protected SearchReturn theSearchrequired for this class.voidOpen the url page<P extends FluentPage>
PgoTo(P page) Open the page, using the url defined in the pagevoidgoToInNewTab(String url) Open the url page in a new tabInject object with FluentLenium resources.injectComponent(Object componentContainer, Object parentContainer, org.openqa.selenium.SearchContext searchContext) Inject object with FluentLenium resources, using given search context and parent container.booleanisComponentClass(Class<?> componentClass) Check if this class is a component class.booleanisComponentListClass(Class<? extends List<?>> componentListClass) Check if this class is a component list class.keyboard()Execute keyboard actionsmouse()Execute mouse actions<T> TnewComponent(Class<T> componentClass, org.openqa.selenium.WebElement element) Create and register a new component of the provided type from the givenWebElement.<L extends List<T>,T>
LnewComponentList(Class<L> listClass, Class<T> componentClass) Create and register an empty list of component.<L extends List<T>,T>
LnewComponentList(Class<L> listClass, Class<T> componentClass, List<T> componentsList) Create and register a new list of component from the given component list.<L extends List<T>,T>
LnewComponentList(Class<L> listClass, Class<T> componentClass, T... componentsList) Create and register a new list of component from the given component list.<T> ComponentList<T>newComponentList(Class<T> componentClass) Create and register an empty list of component.<T> ComponentList<T>newComponentList(Class<T> componentClass, List<T> componentsList) Create and register a new list of component from the given component list.<T> ComponentList<T>newComponentList(Class<T> componentClass, T... componentsList) Create and register a new list of component from the given component list.newFluent(org.openqa.selenium.WebElement element) Create and register a newFluentWebElementfrom the givenWebElement.Create and register an empty fluent list.newFluentList(FluentWebElement... elements) Create and register a new fluent list from the argument FluentWebElements.<T extends FluentWebElement>
FluentList<T>newFluentList(Class<T> componentClass) Create and register an empty fluent list of the provided type.<T extends FluentWebElement>
FluentList<T>newFluentList(Class<T> componentClass, List<T> elements) Create and register a new fluent list.<T extends FluentWebElement>
FluentList<T>newFluentList(Class<T> componentClass, T... elements) Create and register a new fluent list.newFluentList(List<FluentWebElement> elements) Create and register a new fluent list from the argument list of FluentWebElements.<T> TnewInstance(Class<T> cls) Creates a new instance of a class inject it.Return the source of the pageReturns an object for accessing Performance Timing API queries.voidquit()Quit the underlying web driver and release fluent driver resources.voidRelease fluent driver resources.voidswitchTo()Switch to the default elementvoidswitchTo(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)voidswitchTo(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)voidSwitch to the default elementvoidTake a html dump of the browser DOM.voidtakeHtmlDump(String fileName) Take a html dump of the browser DOM into a file given by the fileName param.Take a snapshot of the browser.takeScreenshot(String fileName) Take a snapshot of the browser into a file given by the fileName param.url()Return the url of the page.window()Exposes methods on browser windowMethods inherited from class io.fluentlenium.core.FluentControlImpl
getControlContainer, getFluentControlMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluentlenium.core.FluentControl
getAwaitAtMost, getAwaitPollingEvery, getBaseUrl, getBrowserTimeout, getBrowserTimeoutRetries, getCapabilities, getConfigurationDefaults, getConfigurationFactory, getCustomProperty, getDeleteCookies, getDriverLifecycle, getEventsEnabled, getHtmlDumpMode, getHtmlDumpPath, getImplicitlyWait, getPageLoadTimeout, getRemoteUrl, getScreenshotMode, getScreenshotPath, getScriptTimeout, getWebDriver, setAwaitAtMost, setAwaitPollingEvery, setBaseUrl, setBrowserTimeout, setBrowserTimeoutRetries, setCapabilities, setConfigurationFactory, setCustomProperty, setDeleteCookies, setDriverLifecycle, setEventsEnabled, setHtmlDumpMode, setHtmlDumpPath, setImplicitlyWait, setPageLoadTimeout, setRemoteUrl, setScreenshotMode, setScreenshotPath, setScriptTimeout, setWebDriver
-
Constructor Details
-
FluentDriver
public FluentDriver(org.openqa.selenium.WebDriver driver, Configuration configuration, FluentControl adapter) Wrap the driver into a Fluent driver.- Parameters:
driver- underlying selenium driverconfiguration- configurationadapter- adapter fluent control interface
-
-
Method Details
-
getConfiguration
Description copied from interface:FluentControlGet the test adapter configuration.- Specified by:
getConfigurationin interfaceFluentControl- Overrides:
getConfigurationin classFluentControlImpl- Returns:
- configuration
-
takeHtmlDump
public void takeHtmlDump()Description copied from interface:SnapshotControlTake a html dump of the browser DOM. By default the file will be a html named by the current timestamp. -
takeHtmlDump
Description copied from interface:SnapshotControlTake a html dump of the browser DOM into a file given by the fileName param.- Parameters:
fileName- file name for html dump
-
canTakeScreenShot
public boolean canTakeScreenShot()Description copied from interface:SnapshotControlCheck if underlyingWebDrivercan take screenshot.- Returns:
- true if screenshot can be taken, false otherwise
-
takeScreenshot
Description copied from interface:SnapshotControlTake a snapshot of the browser. By default the file will be a png named by the current timestamp.- Returns:
- the screenshot file
-
takeScreenshot
Description copied from interface:SnapshotControlTake a snapshot of the browser into a file given by the fileName param.- Parameters:
fileName- file name for screenshot- Returns:
- the screenshot file
-
getDriver
public org.openqa.selenium.WebDriver getDriver()Description copied from interface:SeleniumDriverControlGet 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.
- Returns:
- The actual underlying Selenium WebDriver
-
getAppiumDriver
public io.appium.java_client.AppiumDriver getAppiumDriver()Description copied from interface:SeleniumDriverControlGet 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.
- Returns:
- The actual underlying AppiumDriver
-
events
Description copied from interface:EventsControlRetrieves an event registry to register event listeners.- Returns:
- the event registry.
-
mouse
Description copied from interface:InputControlExecute mouse actions- Returns:
- mouse actions object
-
keyboard
Description copied from interface:InputControlExecute keyboard actions- Returns:
- mouse keyboard object
-
window
Description copied from interface:NavigationControlExposes methods on browser window- Returns:
- Window actions
-
await
Description copied from interface:AwaitControlwait for an asynchronous call- Returns:
- FluentWait element
-
getCookies
Description copied from interface:NavigationControlreturn the cookies as a set- Returns:
- set of cookies
-
getCookie
Description copied from interface:NavigationControlreturn the corresponding cookie given a name- Parameters:
name- cookie name- Returns:
- cookie selected by name
-
url
Description copied from interface:NavigationControlReturn the url of the page. If a base url is provided, the current url will be relative to that base url.- Returns:
- current URL
-
pageSource
Description copied from interface:NavigationControlReturn the source of the page- Returns:
- source of the page under test
-
goTo
Description copied from interface:NavigationControlOpen the page, using the url defined in the page- Type Parameters:
P- Type of FluentPage- Parameters:
page- page to open- Returns:
- Opened page.
- See Also:
-
goTo
Description copied from interface:NavigationControlOpen the url page- Parameters:
url- page URL to visit
-
goToInNewTab
Description copied from interface:NavigationControlOpen the url page in a new tab- Parameters:
url- the url of the page
-
capabilities
public org.openqa.selenium.Capabilities capabilities()Description copied from interface:CapabilitiesControlGet the actual capabilities of the underlying Selenium WebDriver.- Returns:
- actual capabilities.
- See Also:
-
executeScript
Description copied from interface:JavascriptControlExecute a script, synchronously.- Parameters:
script- script source to executeargs- script arguments- Returns:
- an object wrapping the result
-
executeAsyncScript
Description copied from interface:JavascriptControlExecute a script, asynchronously.- Parameters:
script- script source to executeargs- script arguments- Returns:
- an object wrapping the result
-
switchTo
Description copied from interface:NavigationControlSwitch to the first selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)- Parameters:
elements- fluent list of fluent web elements
-
switchTo
Description copied from interface:NavigationControlSwitch to the selected Element (if element is null or not an iframe, or doesn't have an id then switch to the default)- Parameters:
element- fluent web element to switch to
-
switchTo
public void switchTo()Description copied from interface:NavigationControlSwitch to the default element -
switchToDefault
public void switchToDefault()Description copied from interface:NavigationControlSwitch to the default element -
alert
Description copied from interface:AlertControlGet an object to control the alert window.- Returns:
- an alert object
-
quit
public void quit()Quit the underlying web driver and release fluent driver resources. -
releaseFluent
public void releaseFluent()Release fluent driver resources. -
getComponentsManager
Returns theComponentsManagerrequired for this class.- Returns:
- the components manager
-
getSearch
Return theSearchrequired for this class.- Returns:
- the Search object
-
inject
Description copied from interface:FluentInjectControlInject object with FluentLenium resources.- Parameters:
container- container to inject with FluentLenium resources- Returns:
- The container context related to the injected container
-
newInstance
Description copied from interface:FluentInjectControlCreates a new instance of a class inject it.- Type Parameters:
T- type of the object- Parameters:
cls- class of the object to create- Returns:
- new container instance
- See Also:
-
injectComponent
public ContainerContext injectComponent(Object componentContainer, Object parentContainer, org.openqa.selenium.SearchContext searchContext) Description copied from interface:FluentInjectControlInject object with FluentLenium resources, using given search context and parent container.- Parameters:
componentContainer- container to inject with FluentLenium resourcesparentContainer- parent containersearchContext- search context to use for injection- Returns:
- The container context related to the injected container
-
css
Description copied from interface:CssControlFeatures related to CSS loaded in the active page.- Returns:
- a CssSupport instance
-
performanceTiming
Description copied from interface:PerformanceTimingControlReturns an object for accessing Performance Timing API queries.- Returns:
- a
PerformanceTimingobject
-
getChromiumApi
Description copied from interface:ChromiumControlFeatures related to browser control under devtools protocol.- Returns:
- a new chromium api instance
-
find
Description copied from interface:SearchControlFind list of elements with CSS selector and filters.- Parameters:
selector- CSS selectorfilters- set of filters- Returns:
- list of element
-
find
Description copied from interface:SearchControlFind list of elements with Selenium locator and filters.- Parameters:
locator- elements locatorfilters- filters set- Returns:
- list of elements
-
find
Description copied from interface:SearchControlFind list of elements with filters.- Parameters:
filters- set of filters in the current context- Returns:
- list of elements
-
find
Description copied from interface:SearchControlWrap raw selenium elements into a list of elements.- Parameters:
rawElements- raw selenium elements- Returns:
- list of element
-
$
Description copied from interface:SearchControlWrap raw selenium elements into a list of elements.- Parameters:
rawElements- raw selenium elements- Returns:
- list of element
-
el
Description copied from interface:SearchControlWrap existing raw selenium element into an element.- Parameters:
rawElement- raw selenium element- Returns:
- element
-
newComponentList
Description copied from interface:ComponentInstantiatorCreate and register an empty list of component.- 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 <T> ComponentList asComponentList(Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentelements- elements- Returns:
- new list of components
-
newComponentList
public <L extends List<T>,T> L newComponentList(Class<L> listClass, Class<T> componentClass, T... componentsList) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given component list.- 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
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new fluent list.- Type Parameters:
T- type of the component- Parameters:
componentClass- class of the componentelements- list of elements- Returns:
- new list of fluent web element
-
isComponentClass
Description copied from interface:ComponentInstantiatorCheck if this class is a component class.- Parameters:
componentClass- class to check- Returns:
- true if this class is a component class, false otherwise
-
asComponentList
public <T> ComponentList<T> asComponentList(Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentelements- elements- Returns:
- new list of components
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(Class<T> componentClass, org.openqa.selenium.WebElement... elements) Description copied from interface:ComponentInstantiatorCreate and register a new fluent list.- Type Parameters:
T- type of the component- Parameters:
componentClass- class of the componentelements- list of elements- Returns:
- new list of fluent web element
-
newFluentList
Description copied from interface:ComponentInstantiatorCreate and register an empty fluent list of the provided type.- Type Parameters:
T- type of the component- Parameters:
componentClass- class of the component- Returns:
- new list of fluent web element
-
newFluent
Description copied from interface:ComponentInstantiatorCreate and register a newFluentWebElementfrom the givenWebElement.- Parameters:
element- wrapped element- Returns:
- new instance of the component
-
isComponentListClass
Description copied from interface:ComponentInstantiatorCheck if this class is a component list class.- Parameters:
componentListClass- class to check- Returns:
- true if this class is a component list class, false otherwise
-
asFluentList
Description copied from interface:ComponentInstantiatorCreate and register a new fluent list from the argument WebElements.- Parameters:
elements- list of elements- Returns:
- new list of fluent web element
-
asFluentList
Description copied from interface:ComponentInstantiatorCreate and register a new fluent list from the argument collection of WebElements.- Parameters:
elements- list of elements- Returns:
- new list of fluent web element
-
asComponentList
public <L extends List<T>,T> L asComponentList(Class<L> listClass, Class<T> componentClass, org.openqa.selenium.WebElement... elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- 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 List<T>,T> L asComponentList(Class<L> listClass, Class<T> componentClass, Iterable<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- 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
-
asFluentList
Description copied from interface:ComponentInstantiatorCreate and register a new fluent list from the argument list of WebElements.- Parameters:
elements- list of elements- Returns:
- new list of fluent web element
-
asFluentList
public <T extends FluentWebElement> FluentList<T> asFluentList(Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new fluent list.- Type Parameters:
T- type of the component- Parameters:
componentClass- class of the componentelements- list of elements- Returns:
- new list of fluent web element
-
asComponentList
public <T> ComponentList<T> asComponentList(Class<T> componentClass, org.openqa.selenium.WebElement... elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentelements- elements- Returns:
- new list of components
-
newComponent
Description copied from interface:ComponentInstantiatorCreate and register a new component of the provided type from the givenWebElement.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentelement- wrapped element- Returns:
- new instance of the component
-
newComponentList
Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given component list.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentcomponentsList- components list- Returns:
- new list of components
-
newComponentList
Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given component list.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the componentcomponentsList- components list- Returns:
- new list of components
-
newComponentList
public <L extends List<T>,T> L newComponentList(Class<L> listClass, Class<T> componentClass, List<T> componentsList) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given component list.- 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
-
newFluentList
Description copied from interface:ComponentInstantiatorCreate and register an empty fluent list.- Returns:
- new list of fluent web element
-
newFluentList
Description copied from interface:ComponentInstantiatorCreate and register a new fluent list from the argument list of FluentWebElements.- Parameters:
elements- list of elements- Returns:
- new list of fluent web element
-
newComponentList
Description copied from interface:ComponentInstantiatorCreate and register an empty list of component.- Type Parameters:
T- type of the component- Parameters:
componentClass- type of the component- Returns:
- new list of components
-
newFluentList
Description copied from interface:ComponentInstantiatorCreate and register a new fluent list from the argument FluentWebElements.- Parameters:
elements- list of elements- Returns:
- new list of fluent web element
-
newFluentList
public <T extends FluentWebElement> FluentList<T> newFluentList(Class<T> componentClass, List<T> elements) Description copied from interface:ComponentInstantiatorCreate and register a new fluent list.- 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(Class<T> componentClass, T... elements) Description copied from interface:ComponentInstantiatorCreate and register a new fluent list.- Type Parameters:
T- type of the component- Parameters:
componentClass- class of the componentelements- list of elements- Returns:
- new list of fluent web element
-
asComponentList
public <L extends List<T>,T> L asComponentList(Class<L> listClass, Class<T> componentClass, List<org.openqa.selenium.WebElement> elements) Description copied from interface:ComponentInstantiatorCreate and register a new list of component from the given element iterable.- 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
-