com.ibm.team.fvt.tests.web
Class WebPage

java.lang.Object
  extended by com.ibm.team.fvt.tests.web.WebPage
Direct Known Subclasses:
LoginPage

public abstract class WebPage
extends java.lang.Object

The abstract class for any web page connected to a WebBrowser.

A web page is created using a location which is the initial url sent to the browser to load the page. It may slightly differ from the browser current url after it has been loaded (see getUrl().

It also stores the configuration used while running the test in order to access any necessary information from it (e.g. timeouts).

Finally, the web page is also associated with a user as its content might slightly or completely differ depending of it. This user let also the page know whether a login operation when a new one is connected to it.

This class provides the following basic functionalities:

It also provides any convenient method to access basic browser functionalities without having to specify all parameters, ie. by using default parameter value:


Constructor Summary
WebPage(java.lang.String url, Config config, User user)
           
 
Method Summary
 void changeUser(User newUser)
          Change the user on the current page.
<P extends WebHover<? extends WebPage>>
P
checkHoverTitle(WebBrowserElement linkElement, java.lang.Class<P> hoverClass)
          Check the hover title of the given link element.
<RH extends WebRichHover<? extends WebPage>>
RH
checkRichHover(WebBrowserElement linkElement, java.lang.Class<RH> richHoverClass, java.lang.String... data)
          Check the rich hover of the given link element.
 WebPage get()
          Get the page content.
 WebBrowser getBrowser()
          Return the browser associated with the current page.
 Config getConfig()
          Return the configuration associated with the current page.
 java.lang.String getLocation()
          Return the page location used when creating it.
static WebPage getPage(java.lang.String location)
          Get from the cache the page instance for the given location.
 User getUser()
          Return the user used when the page was loaded.
 WebPage goBack()
          Move back a single "item" in the browser's history.
 boolean logout(User newUser)
          Logout the page from current user to new user.
static WebPage openPage(java.lang.String location)
           
static
<P extends WebPage>
P
openPage(java.lang.String location, Config config, User user, java.lang.Class<P> pageClass, java.lang.String... data)
          Retrieve the existing page for the given location.
 void refresh()
          Refresh the page content using WebBrowser.refresh() and wait for the page to be loaded (see waitForLoadingPageEnd()).
<RH extends WebRichHover<? extends WebPage>>
RH
richHoverOverLink(WebBrowserElement linkElement, java.lang.Class<RH> richHoverClass, java.lang.String... additionalData)
          Perform a mouse hovering over the given link element.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebPage

public WebPage(java.lang.String url,
               Config config,
               User user)
Method Detail

getPage

public static WebPage getPage(java.lang.String location)
Get from the cache the page instance for the given location.

Parameters:
location - The page location
Returns:
The instance of the class associate with the page or null if this page hasn't been created yet.

openPage

public static WebPage openPage(java.lang.String location)

openPage

public static <P extends WebPage> P openPage(java.lang.String location,
                                             Config config,
                                             User user,
                                             java.lang.Class<P> pageClass,
                                             java.lang.String... data)
Retrieve the existing page for the given location. Create it if it is the first time the page is requested.

Parameters:
location - The url of the page
config - The config to use for the requested page
user - The user to use on the requested page
pageClass - The class associated with the page to open
data - Additional CLM information to be stored in the page
Returns:
The instance of the class associate with the page.

changeUser

public void changeUser(User newUser)
Change the user on the current page.

Parameters:
newUser - The new user to login

checkHoverTitle

public <P extends WebHover<? extends WebPage>> P checkHoverTitle(WebBrowserElement linkElement,
                                                                 java.lang.Class<P> hoverClass)
Check the hover title of the given link element.

This check opens the hover by positioning the mouse pointer over the given link element and checks whether its title matches the given text.

Type Parameters:
P - The expected class for the hover
Parameters:
linkElement - The link on which to hover
hoverClass - The expected class for the hover
Returns:
The opened hover web element as WebBrowserElement
Throws:
ScenarioFailedError - in following cases:
  • The hover is not found (typically when it fails to open)
  • The hover title is not found after shortTimeout() (typically when the hover is still empty when the timeout is reached)
  • The title does not match the expected one
TODO Should infer the hover class as done in ClmProjectAreaPageHelper#checkRichHover(...)

checkRichHover

public <RH extends WebRichHover<? extends WebPage>> RH checkRichHover(WebBrowserElement linkElement,
                                                                      java.lang.Class<RH> richHoverClass,
                                                                      java.lang.String... data)
Check the rich hover of the given link element.

This check opens the rich hover by positioning the mouse pointer over the given link element and perform checks on its content (typically the title).

Type Parameters:
RH - The expected class for the hover
Parameters:
linkElement - The link on which to hover
richHoverClass - The expected class for the hover
Returns:
The opened rich hover web element as WebBrowserElement
Throws:
ScenarioFailedError - in following cases:
  • The rich hover is not found (typically when it fails to open)
  • The rich hover title is not found after shortTimeout() (typically when the hover is still empty when the timeout is reached)
  • The title does not match the expected one
TODO Should infer the hover class as done in ClmProjectAreaPageHelper#checkRichHover(...)

get

public final WebPage get()
Get the page content.

Returns:
The page instance

getBrowser

public WebBrowser getBrowser()
Return the browser associated with the current page.

Returns:
The browser as WebBrowser

getConfig

public Config getConfig()
Return the configuration associated with the current page.

Returns:
The configuration as Config

getLocation

public java.lang.String getLocation()
Return the page location used when creating it.

Returns:
The page location

getUser

public User getUser()
Return the user used when the page was loaded.

Returns:
The user.

goBack

public WebPage goBack()
Move back a single "item" in the browser's history.

See Also:
WebDriver.Navigation#back()

logout

public boolean logout(User newUser)
Logout the page from current user to new user.

Parameters:
newUser -

refresh

public void refresh()
Refresh the page content using WebBrowser.refresh() and wait for the page to be loaded (see waitForLoadingPageEnd()).

If subclass overrides this method, it's strongly recommended to call the super implementation in order to implicitly wait for the end of the page load, but also to set the refreshed flag...


richHoverOverLink

public <RH extends WebRichHover<? extends WebPage>> RH richHoverOverLink(WebBrowserElement linkElement,
                                                                         java.lang.Class<RH> richHoverClass,
                                                                         java.lang.String... additionalData)
Perform a mouse hovering over the given link element.

Type Parameters:
RH - The rich hover specialized class
Parameters:
linkElement - The web element on which to hover
richHoverClass - The rich hover specialized class
additionalData - Additional data to check in the rich hover
Returns:
The opened rich hover as the given specialized class

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object