Package: geb

## [Groovy] Class Page

- geb.Page

- All Implemented Interfaces and Traits:
    Initializable, Navigable, PageContentContainer, WaitingSupport

      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:

  - PageContentSupport
  - DownloadSupport
  - WaitingSupport
  - TextMatchingSupport
  - AlertAndConfirmSupport

  See the chapter in the Geb manual on pages for more information on writing subclasses.

- - ### Properties Summary

    Properties
    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 Summary

    Constructors
    Constructor and description
    `Page ()`

  - ### Methods Summary

    Methods
    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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Property Detail

    - #### static Object at

      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`)

    - #### static Object atCheckWaiting

      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`).

    - #### static Object fragment

      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`)

      See Also:
        to(java.util.Map, geb.url.UrlFragment, java.lang.Object)

    - #### static Object url

      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.

      See Also:
        to(java.util.Map, geb.url.UrlFragment, java.lang.Object)

  - ### Constructor Detail

    - #### Page()

  - ### Method Detail

    - #### 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.

      Returns:
        at verification result with any AssertionError that might have been thrown wrapped up
      See Also:
        AtVerificationResult

    - #### Browser getBrowser()

      The browser that the page is connected to.

    - #### @Override 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.

      See Also:
        Browser.getJs

    - #### UrlFragment getPageFragment()

      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.

      See Also:
        UrlFragment

    - #### protected Wait getPageLevelAtCheckWaiting()

    - #### String getPageUrl()

      Returns the constant part of the url to this page.

      This implementation returns the static `url` property of the class.

    - #### String getPageUrl(String path)

      Returns the url to this page, with path appended to it.

      See Also:
        getPageUrl()

    - #### @Override PageContentContainer getRootContainer()

    - #### boolean getShouldVerifyAtImplicitly()

    - #### String getTitle()

      Returns the title of the current browser window.

      See Also:
        WebDriver.getTitle

    - #### Page init(Browser browser)

      Initialises this page instance, connecting it to the browser.

      This method is called internally, and should not be called by users of Geb.

    - #### @SuppressWarnings(value: [UnusedMethodParameter, EmptyMethod]) void onLoad(Page previousPage)

      Lifecycle method called when the page is connected to the browser.

      This implementation does nothing.

      Parameters:
        `previousPage` - The page that was active before this one

    - #### @SuppressWarnings(value: [UnusedMethodParameter, EmptyMethod]) void onUnload(Page nextPage)

      Lifecycle method called when this page is being replaced as the browser's page instance.

      This implementation does nothing.

      Parameters:
        `nextPage` - The page that will be active after this one

    - #### <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. The page is reloaded using `WebDriver.Navigation#refresh( )` before each evaluation of `block`.

      throws:
        WaitTimeoutException if the block does not produce a true-ish value in time
      Parameters:
        `block` - what is to be waited on to return a true-ish value
      Returns:
        the true-ish return value from `block`
      See Also:
        Configuration.getDefaultWait

    - #### <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. The page is reloaded using `WebDriver.Navigation#refresh( )` before each evaluation of `block`.

      throws:
        WaitTimeoutException if the block does not produce a true-ish value in time
      Parameters:
        `waitPreset` - the name of the wait preset in `configuration` to use
        `block` - what is to be waited on to return a true-ish value
      Returns:
        the true-ish return value from `block`
      See Also:
        Configuration.getWaitPreset

    - #### <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. The page is reloaded using `WebDriver.Navigation#refresh( )` before each evaluation of `block`.

      throws:
        WaitTimeoutException if the block does not produce a true-ish value in time
      Parameters:
        `timeout` - the number of seconds to wait for block to return (roughly)
        `block` - what is to be waited on to return a true-ish value
      Returns:
        the true-ish return value from `block`

    - #### <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. The page is reloaded using `WebDriver.Navigation#refresh( )` before each evaluation of `block`.

      throws:
        WaitTimeoutException if the block does not produce a true-ish value in time
      Parameters:
        `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 value
      Returns:
        the true-ish return value from `block`

    - #### void to(Map params, UrlFragment fragment, Object[] args)

      Sends the browser to this page's url.

      Parameters:
        `params` - query parameters to be appended to the url
        `fragment` - optional url fragment identifier
        `args` - "things" that can be used to generate an extra path to append to this page's url
      See Also:
        convertToPath(java.lang.Object)
        getPageUrl(java.lang.String)

    - #### String toString()

      Returns the name of this class.

      See Also:
        Class.getName

    - #### GebException uninitializedException()

    - #### boolean verifyAt()

      Checks if the browser is not at an unexpected page and then executes this page's "at checker".

      throws:
        AssertionError if this page's "at checker" doesn't pass (with implicit assertions enabled)
      throws:
        UnexpectedPageException when at an unexpected page
      Returns:
        whether the at checker succeeded or not.
      See Also:
        verifyAtSafely(boolean)

    - #### boolean verifyAtSafely(boolean honourGlobalAtCheckWaiting)

      Executes this page's "at checker", suppressing any AssertionError that is thrown and returning false.

      Returns:
        whether the at checker succeeded or not.
      See Also:
        verifyAt()