Class FluentPage
- java.lang.Object
-
- org.fluentlenium.core.FluentControlImpl
-
- org.fluentlenium.core.DefaultFluentContainer
-
- org.fluentlenium.core.FluentPage
-
- All Implemented Interfaces:
Configuration
,ConfigurationMutator
,ConfigurationProperties
,InputControl
,AlertControl
,CapabilitiesControl
,ComponentInstantiator
,CssControl
,EventsControl
,FluentContainer
,FluentControl
,FluentPageControl
,FluentInjectControl
,NavigationControl
,PerformanceTimingControl
,JavascriptControl
,SearchControl<FluentWebElement>
,SeleniumDriverControl
,SnapshotControl
,AwaitControl
,ChromiumControl
public class FluentPage extends DefaultFluentContainer implements FluentPageControl
Use the Page Object Pattern to have more resilient tests.Extend this class and use @
PageUrl
and @FindBy
annotations to provide injectable Page Objects to FluentLenium.Your page object class has to extend this class only when you use the
@PageUrl
annotation as well.A subclass of
FluentPage
may also be annotated with one of Selenium's@Find...
annotation to give an identifier for this page. SeeisAt()
andisAtUsingSelector(By)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fluentlenium.configuration.ConfigurationProperties
ConfigurationProperties.DriverLifecycle, ConfigurationProperties.TriggerMode
-
-
Field Summary
-
Fields inherited from class org.fluentlenium.core.DefaultFluentContainer
control
-
-
Constructor Summary
Constructors Constructor Description FluentPage()
Creates a new fluent page.FluentPage(FluentControl control)
Creates a new fluent page, using given fluent control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassAnnotations
getClassAnnotations()
String
getParam(String parameterName)
Parses the current URL and returns the parameter value for the argument parameter name.String
getUrl()
Gets the URL of the page.String
getUrl(Object... parameters)
URL of the page, after replacing parameters with given values.<P extends FluentPage>
Pgo()
Go to the url defined in the page<P extends FluentPage>
Pgo(Object... params)
Got to the url defined in the page, using given parameters.void
isAt()
Check if the browser is on this page.void
isAt(Object... parameters)
Check if the browser is on this page, after replacing parameters with given values.void
isAtUsingSelector(org.openqa.selenium.By by)
Validates whether the page, determined by the argumentBy
object, is loaded.void
isAtUsingUrl(String urlTemplate)
URL-matching implementation for isAt().ParsedUrlTemplate
parseUrl()
Get the parameter values of page URL extracted from current URL.ParsedUrlTemplate
parseUrl(String url)
Get the parameter values of page URL extracted from given URL.void
unshadowAllFields()
void
verifyIsLoaded()
Verifies whether page is loaded.-
Methods inherited from class org.fluentlenium.core.DefaultFluentContainer
getDriver, getFluentControl, initFluent
-
Methods inherited from class org.fluentlenium.core.FluentControlImpl
getConfiguration, getControlContainer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fluentlenium.core.FluentControl
alert, asComponentList, asComponentList, asComponentList, asComponentList, asComponentList, asComponentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, asFluentList, await, canTakeScreenShot, capabilities, css, el, events, executeAsyncScript, executeScript, find, find, find, find, getAppiumDriver, getAwaitAtMost, getAwaitPollingEvery, getBaseUrl, getBrowserTimeout, getBrowserTimeoutRetries, getCapabilities, getChromiumApi, getConfiguration, getConfigurationDefaults, getConfigurationFactory, getControlContainer, getCookie, getCookies, getCustomProperty, getDeleteCookies, getDriver, getDriverLifecycle, getEventsEnabled, getFluentControl, getHtmlDumpMode, getHtmlDumpPath, getImplicitlyWait, getPageLoadTimeout, getRemoteUrl, getScreenshotMode, getScreenshotPath, getScriptTimeout, getWebDriver, goTo, goTo, goToInNewTab, inject, injectComponent, isComponentClass, isComponentListClass, keyboard, mouse, newComponent, newComponentList, newComponentList, newComponentList, newComponentList, newComponentList, newComponentList, newFluent, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList, newFluentList, newInstance, pageSource, performanceTiming, setAwaitAtMost, setAwaitPollingEvery, setBaseUrl, setBrowserTimeout, setBrowserTimeoutRetries, setCapabilities, setConfigurationFactory, setCustomProperty, setDeleteCookies, setDriverLifecycle, setEventsEnabled, setHtmlDumpMode, setHtmlDumpPath, setImplicitlyWait, setPageLoadTimeout, setRemoteUrl, setScreenshotMode, setScreenshotPath, setScriptTimeout, setWebDriver, switchTo, switchTo, switchTo, switchToDefault, takeHtmlDump, takeHtmlDump, takeScreenshot, takeScreenshot, url, window
-
-
-
-
Constructor Detail
-
FluentPage
public FluentPage()
Creates a new fluent page.
-
FluentPage
public FluentPage(FluentControl control)
Creates a new fluent page, using given fluent control.- Parameters:
control
- fluent control
-
-
Method Detail
-
getClassAnnotations
public ClassAnnotations getClassAnnotations()
-
getUrl
public String getUrl()
Description copied from interface:FluentPageControl
Gets the URL of the page. It can contain mandatory parameters{param}
and optional parameters{?param1}
.- Specified by:
getUrl
in interfaceFluentPageControl
- Returns:
- page URL
-
getParam
public String getParam(String parameterName)
Parses the current URL and returns the parameter value for the argument parameter name.In case the parameter is not defined in the
PageUrl
annotation, or the parameter (mandatory or optional) has no value in the actual URL, this method returnsnull
.There is also caching in place to improve performance. It compares the current URL with the cached URL, and if they are the same, the parameter is returned from the cached values, otherwise the URL is parsed again and the parameters are returned from the new URL.
Examples (for template + URL + paramName combinations):
"/abc/{param1}/def/{param2}" + "/abc/param1val/def/param2val" + "param1" -> "param1val" "/abc/{param1}/def/{param2}" + "/abc/param1val/def/param2val" + "param4" -> null "/abc{?/param1}/def/{param2}" + "/abc/param1val/def/param2val" + "param1" -> "param1val" "/abc{?/param1}/def/{param2}" + "/abc/def/param2val" + "param1" -> ull
- Parameters:
parameterName
- the parameter to get the value of- Returns:
- the desired parameter value or null if a value for the given parameter name is not present
- Throws:
IllegalArgumentException
- when the argument param is null or empty
-
getUrl
public String getUrl(Object... parameters)
Description copied from interface:FluentPageControl
URL of the page, after replacing parameters with given values.- Specified by:
getUrl
in interfaceFluentPageControl
- Parameters:
parameters
- parameter values- Returns:
- Effective url generated for given parameter values
-
isAt
public void isAt()
Description copied from interface:FluentPageControl
Check if the browser is on this page.- Specified by:
isAt
in interfaceFluentPageControl
-
isAt
public void isAt(Object... parameters)
Description copied from interface:FluentPageControl
Check if the browser is on this page, after replacing parameters with given values.- Specified by:
isAt
in interfaceFluentPageControl
- Parameters:
parameters
- list of parameters
-
isAtUsingUrl
public void isAtUsingUrl(String urlTemplate)
URL-matching implementation for isAt(). Validates whether the page, determined by the argument URL template, is loaded.If there is a
PageUrl
annotation applied on the class and it has thefile
attribute defined, this method will skip the url parsing to skip URL check because it is not able to get local file path relatively.- Parameters:
urlTemplate
- URL Template, must be non-null- Throws:
AssertionError
- when the current URL doesn't match the expected page URL
-
isAtUsingSelector
public void isAtUsingSelector(org.openqa.selenium.By by)
Validates whether the page, determined by the argumentBy
object, is loaded.- Parameters:
by
- by selector, must be non-null- Throws:
AssertionError
- if the element using the argument By is not found for the current page
-
go
public <P extends FluentPage> P go()
Description copied from interface:FluentPageControl
Go to the url defined in the page- Specified by:
go
in interfaceFluentPageControl
- Type Parameters:
P
- the fluent page- Returns:
FluentPage object
-
go
public <P extends FluentPage> P go(Object... params)
Description copied from interface:FluentPageControl
Got to the url defined in the page, using given parameters.- Specified by:
go
in interfaceFluentPageControl
- Type Parameters:
P
- the fluent page- Parameters:
params
- page url parameter values- Returns:
FluentPage object
-
parseUrl
public ParsedUrlTemplate parseUrl()
Description copied from interface:FluentPageControl
Get the parameter values of page URL extracted from current URL.- Specified by:
parseUrl
in interfaceFluentPageControl
- Returns:
- parameter values
-
verifyIsLoaded
public void verifyIsLoaded()
-
unshadowAllFields
public void unshadowAllFields()
-
parseUrl
public ParsedUrlTemplate parseUrl(String url)
Description copied from interface:FluentPageControl
Get the parameter values of page URL extracted from given URL.- Specified by:
parseUrl
in interfaceFluentPageControl
- Parameters:
url
- url to parse- Returns:
- parameter values
-
-