Follow

How can multiple parents be supported in page hierarchy?

The framework has multiple route support. In case of multiple route, to navigate to specific page you need to define launcher interface that extends BaseTestPage and provide that interface as parent to the page with multiple route.Implement launcher interface in each possible parent class. At the time of defining test provide parent as argument while creating page object.


Here is the example for better understanding:

interface MultiRoutePageLauncher extends TestPage {
public void launchMultiRoutePage(PageLocator loc);
}


public class MultiRoutePage extends BaseTestPage {

public MultiRoutePage(MultiRoutePageLauncher parent) {
super(parent);
}


public MultiRoutePage() {
// either provide default route
//or remove this constructor

this(new Route1Page());
}

@Override
protected void openPage(PageLocator loc) {
parent.launchMultiRoutePage(loc);

}

}


public class Route1Page extends BaseTestPage implements MultiRoutePageLauncher {
@Override
public void launchMultiRoutePage(PageLocator loc) {
// steps to open page.
}

}


public class Route2Page extends BaseTestPage implements MultiRoutePageLauncher {
@Override
public void launchMultiRoutePage(PageLocator loc) {
// steps to open page.
}

}


Your test method will look like:


@Test
public void testMethod() {
// Default Route
MultiRoutePage multiRoutePage = new MultiRoutePage();
// route 1
// MultiRoutePage multiRoutePage = new MultiRoutePage(new Route1Page());
// route 2
//MultiRoutePage multiRoutePage = new MultiRoutePage(new Route2Page());
MultiRoutePage.launchPage(pageLocator);

}

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk