|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.team.fvt.tests.web.WebPage
public abstract class WebPage
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 getUser()
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:
get()
: get page content.getPage(String)
: Get from the cache the page instance for the
given location.startNewBrowserSession()
: Close the current browser session and
open a new one.
Field Summary | |
---|---|
static java.lang.String[] |
NO_DATA
|
Constructor Summary | |
---|---|
WebPage(java.lang.String url,
Config config,
User user)
|
Method Summary | ||
---|---|---|
|
checkHoverTitle(WebBrowserElement linkElement,
java.lang.Class<P> hoverClass)
Check the hover title of the given link element. |
|
|
checkRichHover(WebBrowserElement linkElement,
java.lang.Class<RH> richHoverClass,
java.lang.String... data)
Check the rich hover of the given link element. |
|
static void |
clearHistory()
Clear web pages history. |
|
boolean |
equals(java.lang.Object o)
|
|
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. |
|
static WebPage |
getCurrentPage()
Return the current page displayed on the browser. |
|
java.lang.String |
getLocation()
Return the page location used when creating it. |
|
static
|
getPage(java.lang.Class<P> pageClass)
Seek the cache to find the instance of the given page class. |
|
static WebPage |
getPage(java.lang.String location)
Get from the cache the page instance for the given location. |
|
static WebPage |
getPageUsingBrowser(Config config)
Retrieve the existing page for the browser current URL. |
|
abstract java.lang.String |
getTitle()
Return the title of the page. |
|
java.lang.String |
getUrl()
Return the URL of the page loaded in the browser. |
|
User |
getUser()
Return the user used when the page was loaded. |
|
WebPage |
goBack()
Move back a single "item" in the browser's history. |
|
int |
hashCode()
|
|
boolean |
login(User user)
Login the page from current user to the given user. |
|
boolean |
login(User user,
boolean force)
Login the page from current user to the given user. |
|
static WebPage |
openPage(java.lang.String location)
|
|
static
|
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. |
|
|
openPageUsingBrowser(java.lang.Class<P> pageClass,
java.lang.String... data)
Retrieve the existing page for the browser current URL. |
|
|
openPageUsingHoverTitle(WebRichHover<? extends WebPage> hover,
java.lang.Class<P> openedPageClass,
java.lang.String... data)
Click on the given hover title to open a new page. |
|
|
openPageUsingLink(org.openqa.selenium.By linkBy,
java.lang.Class<P> openedPageClass)
Click on the link found using the given mechanism assuming that will open a new page . |
|
|
openPageUsingLink(org.openqa.selenium.By linkBy,
java.lang.Class<P> openedPageClass,
int timeOut)
Click on the link found using the given mechanism assuming that will open a new page . |
|
|
openPageUsingLink(org.openqa.selenium.By linkBy,
java.lang.Class<P> openedPageClass,
java.lang.String... info)
Click on the link found using the given mechanism assuming that will open a new page . |
|
|
openPageUsingLink(WebBrowserElement parentElement,
org.openqa.selenium.By linkBy,
java.lang.Class<P> openedPageClass)
Click on the link found using the given mechanism assuming that will open a new page . |
|
|
openPageUsingLink(WebBrowserElement parentElement,
org.openqa.selenium.By linkBy,
java.lang.Class<P> openedPageClass,
boolean fail,
int time_out,
java.lang.String... info)
Click on the link found using the given mechanism assuming that will open a new page . |
|
|
openPageUsingLink(WebBrowserElement linkElement,
java.lang.Class<P> openedPageClass,
java.lang.String... data)
Click on the given link assuming that will open a new page. |
|
void |
parkMouse()
Park the mouse at a location where links are not found in order to prevent unexpected rich hovers from loading by accident. |
|
void |
refresh()
Refresh the page content using WebBrowser.refresh() and wait for
the page to be loaded (see waitForLoadingPageEnd() ). |
|
|
richHoverOverLink(WebBrowserElement linkElement,
java.lang.Class<RH> richHoverClass,
java.lang.String... additionalData)
Perform a mouse hovering over the given link element. |
|
static WebPage |
searchPageInHistory(java.lang.String location)
Return the first page found in the history. |
|
void |
takeSnapshotFailure(java.lang.String fileName)
Takes a failure snapshot. |
|
void |
takeSnapshotInfo(java.lang.String fileName)
Takes an information snapshot. |
|
void |
takeSnapshotWarning(java.lang.String fileName)
Takes a warning snapshot. |
|
java.lang.String |
toString()
|
|
WebBrowserElement |
waitForElement(org.openqa.selenium.By parentBy,
org.openqa.selenium.By findBy,
boolean fail,
int time_out)
Wait until have found the web element relatively to a parent element using the respective given mechanisms. |
|
java.lang.String |
waitForText(WebBrowserElement element,
boolean fail,
int time_out,
java.lang.String... texts)
Wait until have got one of the expected texts on of the given element. |
|
WebBrowserElement |
waitForTextPresent(java.lang.String... texts)
Wait until have got one of the expected texts on of the given element. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] NO_DATA
Constructor Detail |
---|
public WebPage(java.lang.String url, Config config, User user)
Method Detail |
---|
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static void clearHistory()
public static WebPage searchPageInHistory(java.lang.String location)
location
- The page location
null
if none was found.public static WebPage getCurrentPage()
This is the last page of the internal cache.
WebPage
.public static <P extends WebPage> P getPage(java.lang.Class<P> pageClass)
Note that this is a very expensive method which should not be used too frequently.
TODO Replace the pages cache keys to store class instead location.
pageClass
- The page class
null
if this page hasn't been created yet.public static WebPage getPage(java.lang.String location)
location
- The page location
null
if this page hasn't been created yet.public static WebPage getPageUsingBrowser(Config config)
null
if no page location matching the browser url is found in the cache...public static WebPage openPage(java.lang.String location)
public static <P extends WebPage> P openPage(java.lang.String location, Config config, User user, java.lang.Class<P> pageClass, java.lang.String... data)
location
- The url of the pageconfig
- The config to use for the requested pageuser
- The user to use on the requested pagepageClass
- The class associated with the page to opendata
- Additional CLM information to be stored in the page
public <P extends WebLinkHover<? extends WebPage>> P checkHoverTitle(WebBrowserElement linkElement, java.lang.Class<P> hoverClass)
This check opens the hover by positioning the mouse pointer over the given link element and checks whether its title matches the given text.
P
- The expected class for the hoverlinkElement
- The link on which to hoverhoverClass
- The expected class for the hover
WebBrowserElement
ScenarioFailedError
- in following cases:
shortTimeout()
(typically
when the hover is still empty when the timeout is reached)public <RH extends WebRichHover<? extends WebPage>> RH checkRichHover(WebBrowserElement linkElement, java.lang.Class<RH> richHoverClass, java.lang.String... data)
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).
RH
- The expected class for the hoverlinkElement
- The link on which to hoverrichHoverClass
- The expected class for the hover
WebBrowserElement
ScenarioFailedError
- in following cases:
shortTimeout()
(typically
when the hover is still empty when the timeout is reached)public final WebPage get()
public WebBrowser getBrowser()
WebBrowser
public Config getConfig()
Config
public java.lang.String getLocation()
public abstract java.lang.String getTitle()
String
.public final java.lang.String getUrl()
String
WebBrowser.getCurrentUrl()
public User getUser()
user
.public WebPage goBack()
WebBrowser.back()
public void parkMouse()
public boolean login(User user)
Nothing happen if the current user is already logged in.
user
- The user to log in.public boolean login(User user, boolean force)
Nothing happen if the current user is already logged in.
user
- The user to log in.force
- Force the user login, even if it's already loggedpublic <P extends WebPage> P openPageUsingBrowser(java.lang.Class<P> pageClass, java.lang.String... data)
pageClass
- The class associated with the page to opendata
- Additional CLM information to be stored in the page
public <P extends WebPage> P openPageUsingHoverTitle(WebRichHover<? extends WebPage> hover, java.lang.Class<P> openedPageClass, java.lang.String... data)
Note that the browser url after having clicked on the hover title will be used for the page location.
hover
- The hover on which to click on titleopenedPageClass
- The class associated with the opened pagedata
- Provide additional information to store in the page when opening it
WebPage
) opened after
having clicked on the linkopenPage(String, Config, User, Class, String...)
,
WebBrowserElement.click()
public <P extends WebPage> P openPageUsingLink(org.openqa.selenium.By linkBy, java.lang.Class<P> openedPageClass)
page
.
The opened page URL is got from the application which usually takes it from
the href
attribute of the link web element (see
Topology.getPageUrl(String)
.
Note that:
timeout()
seconds
linkBy
- The mechanism to find the link element in the current pageopenedPageClass
- The class associated with the opened page
WebPage
) opened after
having clicked on the linkopenPageUsingLink(WebBrowserElement, By, Class, boolean, int, String...)
public <P extends WebPage> P openPageUsingLink(org.openqa.selenium.By linkBy, java.lang.Class<P> openedPageClass, int timeOut)
page
.
The opened page URL is got from the application which usually takes it from
the href
attribute of the link web element (see
Topology.getPageUrl(String)
.
Note that:
timeout()
seconds
linkBy
- The mechanism to find the link element in the current pageopenedPageClass
- The class associated with the opened pagetimeOut
- Seconds to wait before giving up if the web element is not
found.
WebPage
) opened after
having clicked on the linkopenPageUsingLink(WebBrowserElement, By, Class, boolean, int, String...)
public <P extends WebPage> P openPageUsingLink(org.openqa.selenium.By linkBy, java.lang.Class<P> openedPageClass, java.lang.String... info)
page
.
The opened page URL is got from the application which usually takes it from
the href
attribute of the link web element (see
Topology.getPageUrl(String)
.
Note that:
timeout()
seconds
linkBy
- The mechanism to find the link element in the current pageopenedPageClass
- The class associated with the opened pageinfo
- Provide additional information to store in the page when opening it
WebPage
) opened after
having clicked on the linkopenPageUsingLink(WebBrowserElement, By, Class, boolean, int, String...)
public <P extends WebPage> P openPageUsingLink(WebBrowserElement parentElement, org.openqa.selenium.By linkBy, java.lang.Class<P> openedPageClass)
page
.
The opened page URL is got from the application which usually takes it from
the href
attribute of the link web element (see
Topology.getPageUrl(String)
.
Note that:
timeout()
seconds
parentElement
- The parent element where to start to search from,
if null
, then search in the entire page contentlinkBy
- The mechanism to find the link element in the current pageopenedPageClass
- The class associated with the opened page
WebPage
) opened after
having clicked on the linkopenPageUsingLink(WebBrowserElement, By, Class, boolean, int, String...)
public <P extends WebPage> P openPageUsingLink(WebBrowserElement parentElement, org.openqa.selenium.By linkBy, java.lang.Class<P> openedPageClass, boolean fail, int time_out, java.lang.String... info)
page
.
The opened page URL is got from the application which usually takes it from
the href
attribute of the link web element (see
Topology.getPageUrl(String)
.
parentElement
- The parent element where to start to search from,
if null
, then search in the entire page contentlinkBy
- The mechanism to find the link element in the current pageopenedPageClass
- The class associated with the opened pagefail
- Tells whether to fail if none of the elements is find before timeouttime_out
- The time to wait before giving up the researchinfo
- Provide additional information to store in the page when opening it
WebPage
) opened after
having clicked on the linkWebBrowser.waitForElement(WebBrowserElement, By, boolean, int, boolean, boolean)
,
openPageUsingLink(WebBrowserElement, Class, String...)
,
WebBrowserElement.click()
public <P extends WebPage> P openPageUsingLink(WebBrowserElement linkElement, java.lang.Class<P> openedPageClass, java.lang.String... data)
The opened page URL is got from the application (see
Topology.getPageUrl(String)
) which usually takes
it from the href
attribute of the link web element.
linkElement
- The link on which to clickopenedPageClass
- The class associated with the opened pagedata
- Provide additional information to store in the page when opening it
WebPage
) opened after
having clicked on the linkpublic void refresh()
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...
public <RH extends WebTextHover> RH richHoverOverLink(WebBrowserElement linkElement, java.lang.Class<RH> richHoverClass, java.lang.String... additionalData)
RH
- The rich hover specialized classlinkElement
- The web element on which to hoverrichHoverClass
- The rich hover specialized classadditionalData
- Additional data to check in the rich hover
public void takeSnapshotFailure(java.lang.String fileName)
fileName
- The name of the snapshot file.public void takeSnapshotInfo(java.lang.String fileName)
fileName
- The name of the snapshot file.public void takeSnapshotWarning(java.lang.String fileName)
fileName
- The name of the snapshot file.public java.lang.String toString()
toString
in class java.lang.Object
public WebBrowserElement waitForElement(org.openqa.selenium.By parentBy, org.openqa.selenium.By findBy, boolean fail, int time_out)
Note that:
parentBy
- The mechanism to find the parent element in the current
page, if null
, the element will be searched in the entire page
contentfindBy
- The mechanism to find the element in the current page or
from the given parent element if not null
fail
- Tells whether to fail if none of the elements is find before timeouttime_out
- The time to wait before giving up the research
WebBrowserElement
or null
if no element was found before the timeout and asked not to fail
ScenarioFailedError
- if no element was found before the timeout and
asked to failWebBrowser.waitForElement(WebBrowserElement, By, boolean, int, boolean, boolean)
public java.lang.String waitForText(WebBrowserElement element, boolean fail, int time_out, java.lang.String... texts)
Note that:
timeout()
seconds
element
- The text element to be readfail
- Tells whether to fail if none of the elements is find before timeouttime_out
- The time to wait before giving up the researchtexts
- The expected texts
String
or null
if element text never matches one before the timeout and asked not to fail
ScenarioFailedError
- if element text never matches an expected ones
before the timeout and asked to failWebBrowser.waitForText(WebBrowserElement, boolean, int, String...)
public WebBrowserElement waitForTextPresent(java.lang.String... texts)
Note that:
timeout()
seconds
texts
- The expected texts
String
or null
if element text never matches one before the timeout and asked not to fail
ScenarioFailedError
- if element text never matches an expected ones
before the timeout and asked to failWebBrowser.waitForText(WebBrowserElement, boolean, int, String...)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |