class Page extends Object implements Initializable, Navigable, PageContentContainer, WaitingSupport
The Page type is the basis of the Page Object pattern in Geb.
This implementation is a generic model of every page. Subclasses add methods and content definitions that model specific pages.
This class (or subclasses) should not be instantiated directly.
The following classes are also mixed in to this class:
See the chapter in the Geb manual on pages for more information on writing subclasses.
Type | Name and description |
---|---|
static Object |
at The "at checker" for this page. |
static Object |
atCheckWaiting The wait time configuration for 'at' checking specific to this page. |
static Object |
fragment Defines the url fragment for this page to be used when navigating directly to this page. |
static Object |
url Defines the url for this page to be used when navigating directly to this page. |
Constructor and description |
---|
Page() |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
at(Object[] args) |
|
String |
convertToPath(Object[] args) |
|
AtVerificationResult |
getAtVerificationResult(boolean honourGlobalAtCheckWaiting) Executes this page's "at checker" and captures the result wrapping up any AssertionError that might have been thrown. |
|
Browser |
getBrowser() The browser that the page is connected to. |
|
List<String> |
getContentPath() |
|
WebDriver |
getDriver() The driver of the browser that the page is connected to. |
|
JavascriptInterface |
getJs() Provides access to the browser object's JavaScript interface. |
|
UrlFragment |
getPageFragment() Returns the fragment part of the url to this page. |
|
protected Wait |
getPageLevelAtCheckWaiting() |
|
String |
getPageUrl() Returns the constant part of the url to this page. |
|
String |
getPageUrl(String path) Returns the url to this page, with path appended to it. |
|
PageContentContainer |
getRootContainer() |
|
boolean |
getShouldVerifyAtImplicitly() |
|
String |
getTitle() Returns the title of the current browser window. |
|
Page |
init(Browser browser) Initialises this page instance, connecting it to the browser. |
|
void |
onLoad(Page previousPage) Lifecycle method called when the page is connected to the browser. |
|
void |
onUnload(Page nextPage) Lifecycle method called when this page is being replaced as the browser's page instance. |
<T> |
T |
refreshWaitFor(Map params, Closure<T> block) Uses the default wait from the configuration to
wait for block to return a true value according to the Groovy Truth.
|
<T> |
T |
refreshWaitFor(Map params, String waitPreset, Closure<T> block) Uses the wait preset from the configuration
with the given name to to wait for block to return a true value according to the Groovy Truth.
|
<T> |
T |
refreshWaitFor(Map params, Number timeout, Closure<T> block) Invokes block every Configuration.getDefaultWaitRetryInterval seconds, until it returns
a true value according to the Groovy Truth, waiting at most timeout seconds.
|
<T> |
T |
refreshWaitFor(Map params, Number timeout, Number interval, Closure<T> block) Invokes block every interval seconds, until it returns
a true value according to the Groovy Truth, waiting at most timeout seconds.
|
|
void |
to(Map params, UrlFragment fragment, Object[] args) Sends the browser to this page's url. |
|
String |
toString() Returns the name of this class. |
|
GebException |
uninitializedException() |
|
boolean |
verifyAt() Checks if the browser is not at an unexpected page and then executes this page's "at checker". |
|
boolean |
verifyAtSafely(boolean honourGlobalAtCheckWaiting) Executes this page's "at checker", suppressing any AssertionError that is thrown and returning false. |
The "at checker" for this page.
Subclasses should define a closure here that verifies that the browser is at this page.
This implementation does not have an at checker (i.e. this property is null
)
The wait time configuration for 'at' checking specific to this page.
Subclasses can specify atCheckWaiting value, value specified in page takes priority over the global atCheckWaiting setting.
Possible values for the atCheckWaiting option are consistent with the ones for wait option of content definitions.
This implementation does not have any value for atCheckWaiting (i.e. this property is null
).
Defines the url fragment for this page to be used when navigating directly to this page.
Subclasses can specify either a String
which will be used as is or a Map
which will be translated into an application/x-www-form-urlencoded String
.
The value used will be escaped appropriately so there is no need to escape it yourself.
This implementation does not define a page fragment (i.e. this property is null
)
Defines the url for this page to be used when navigating directly to this page.
Subclasses can specify either an absolute url, or one relative to the browser's base url.
This implementation returns an empty string.
Executes this page's "at checker" and captures the result wrapping up any AssertionError that might have been thrown.
The browser that the page is connected to.
The driver of the browser that the page is connected to.
Provides access to the browser object's JavaScript interface.
Returns the fragment part of the url to this page.
This implementation returns the static fragment
property of the class wrapped in a UrlFragment
instance.
Returns the constant part of the url to this page.
This implementation returns the static url
property of the class.
Returns the url to this page, with path appended to it.
Returns the title of the current browser window.
Initialises this page instance, connecting it to the browser.
This method is called internally, and should not be called by users of Geb.
Lifecycle method called when the page is connected to the browser.
This implementation does nothing.
previousPage
- The page that was active before this oneLifecycle method called when this page is being replaced as the browser's page instance.
This implementation does nothing.
nextPage
- The page that will be active after this one Uses the default wait from the configuration
to
wait for block
to return a true value according to the Groovy Truth.
The page is reloaded using WebDriver.Navigation#refresh( )
before each evaluation of block
.
block
- what is to be waited on to return a true-ish valueblock
Uses the wait preset from the configuration
with the given name to to wait for block
to return a true value according to the Groovy Truth.
The page is reloaded using WebDriver.Navigation#refresh( )
before each evaluation of block
.
waitPreset
- the name of the wait preset in configuration
to useblock
- what is to be waited on to return a true-ish valueblock
Invokes block
every Configuration.getDefaultWaitRetryInterval seconds, until it returns
a true value according to the Groovy Truth, waiting at most timeout
seconds.
The page is reloaded using WebDriver.Navigation#refresh( )
before each evaluation of block
.
timeout
- the number of seconds to wait for block to return (roughly)block
- what is to be waited on to return a true-ish valueblock
Invokes block
every interval
seconds, until it returns
a true value according to the Groovy Truth, waiting at most timeout
seconds.
The page is reloaded using WebDriver.Navigation#refresh( )
before each evaluation of block
.
interval
- the number of seconds to wait between invoking block
timeout
- the number of seconds to wait for block to return (roughly)block
- what is to be waited on to return a true-ish valueblock
Sends the browser to this page's url.
params
- query parameters to be appended to the urlfragment
- optional url fragment identifierargs
- "things" that can be used to generate an extra path to append to this page's urlReturns the name of this class.
Checks if the browser is not at an unexpected page and then executes this page's "at checker".
Executes this page's "at checker", suppressing any AssertionError that is thrown and returning false.
Groovy API Documentation for Geb 7.0 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org