P
- parent page in hierarchyD
- Driver implementation - e.g. selenium or webdriverpublic abstract class AbstractTestPage<P extends TestPage<D>,D> extends java.lang.Object implements TestPage<D>
This class provides you a way to define static or dynamic page hierarchy. In
the case of page hierarchy, you just need to call launch page method of the
object. it takes care of not only launching that page but also the entire
page hierarchy to reach that specific page. Furthermore it also checks that
is page already active in browser? If so then it will continue from there,
results in reduced execution time. It also allows you to set one of the
launch strategy
so that you can specify launch behavior before launching the
page. The default launch strategy is launch only if required
.
When functionality changes only the specific test page file needs to be updated: if there is any change in page/ui of web/native AUT you need to update just in particular page rather than each and every test case, thus result in less maintenance.
By implementation of test page concept in a best efficient way, you can manipulate page navigation same as on actual web application under test. Once page get created page object's functionalities can be used in any test case, makes code more reusable.
TestPage.LaunchStrategy
Modifier and Type | Field and Description |
---|---|
protected D |
driver |
protected java.lang.Object[] |
launchArguments |
protected TestPage.LaunchStrategy |
launchStrategy |
protected org.apache.commons.logging.Log |
logger |
protected PageLocator |
pageLocator |
protected PropertyUtil |
pageProps |
protected P |
parent |
protected UiTestBase<D> |
testbase |
Constructor and Description |
---|
AbstractTestPage(UiTestBase<D> testBase) |
AbstractTestPage(UiTestBase<D> testBase,
P parent2) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterLaunch()
this method can be override to provide tasks to be done immediate after
page launch.
|
void |
assertActive() |
protected void |
beforeLaunch(java.lang.Object... args)
you can override this method to fech any information/data from parent
page before launching the page.
|
PageLocator |
getPageLocator() |
P |
getParent() |
UiTestBase<D> |
getTestBase()
selenium base instance to provide selenium
|
protected void |
initParent() |
boolean |
isPageActive(PageLocator loc,
java.lang.Object... args)
This method check for existence of page in browser so we can proceed
further with page functionality.
|
void |
launchPage(PageLocator locator,
java.lang.Object... args)
Use only launchPage method to load a page.
|
protected abstract void |
openPage(PageLocator locator,
java.lang.Object... args)
Do not provide steps to load this page in this method, Instead provide
steps in method of parent and call that method over here.
In case of multiple parent or referrer page, provide code to get parent by casting. |
void |
setLaunchStrategy(TestPage.LaunchStrategy strategy)
You can specify launch behavior before launching the page by calling this
method.
|
void |
waitForAjaxToComplete()
for any kit
|
void |
waitForImageToLoad(java.lang.String imgLoc)
Deprecated.
|
void |
waitForPageToLoad() |
protected UiTestBase<D> testbase
protected D driver
protected PropertyUtil pageProps
protected PageLocator pageLocator
protected java.lang.Object[] launchArguments
protected final org.apache.commons.logging.Log logger
protected TestPage.LaunchStrategy launchStrategy
public AbstractTestPage(UiTestBase<D> testBase)
public AbstractTestPage(UiTestBase<D> testBase, P parent2)
public UiTestBase<D> getTestBase()
TestPage
getTestBase
in interface TestPage<D>
public PageLocator getPageLocator()
getPageLocator
in interface TestPage<D>
public void setLaunchStrategy(TestPage.LaunchStrategy strategy)
TestPage
setLaunchStrategy
in interface TestPage<D>
strategy
- launch strategy.public void launchPage(PageLocator locator, java.lang.Object... args)
TestPage
void launchPage(){
launchPage(null)
}
OR
void launchPage(String locator){
launchPage(new DefaultPageLocator(locator));
}
launchPage
in interface TestPage<D>
locator
- to locate page on parent page.
This locator will be passed to other fw methods for example
TestPage.isPageActive(PageLocator, Object...)
args
- optional page identifiers to verify is this page for what we
aspect? for example: view details page for specific user or
item, you can identify page by user or item id/name
This args will be passed to other fw methods for example
TestPage.isPageActive(PageLocator, Object...)
public void waitForPageToLoad()
public boolean isPageActive(PageLocator loc, java.lang.Object... args)
TestPage
isPageActive
in interface TestPage<D>
args
- optional arguments required to identify page.protected void afterLaunch()
protected void beforeLaunch(java.lang.Object... args)
Note: If launch method found this page is not opened and going to open the page then only this method will get executed.
args
- passed in launchPage(PageLocator, Object...)
protected void initParent()
protected abstract void openPage(PageLocator locator, java.lang.Object... args)
if(parent instanceof UploadStatus ){
UploadStatus parent = (UploadStatus) getParent();
parent.methodToLoadThisPage(args_if_any);
}
locator
- args
- public void assertActive()
@Deprecated public void waitForImageToLoad(java.lang.String imgLoc)
public void waitForAjaxToComplete()
Copyright © 2000 Infostretch Corp.