I need to refactor my Selenium tests, and was wondering what the best design solution would be for a portal with a hierarchical page organization. We are using tiles, and we have defined a baselayout from which many pages inherit.
Consider the following simplified example:
- baselayout
- start
- about
What would be better, an inherited based design:
/** Implements methods that access the top-level menu. */
Class BaseLayout {...}
/** Implements methods that access elements of the "Start" page */
Class StartPage extends Base Layout {...}
/** Implements methods that access elements of the "About" page */
Class AboutPage extends Base Layout {...}
or an aggregation based design?:
/** Implements methods that access the top-level menu. */
Class BaseLayout {...}
/** Implements methods that access elements of the "Start" page */
Class StartPage {
BaseLayout parent;
// ...
}
/** Implements methods that access elements of the "About" page */
Class AboutPage {
BaseLayout parent;
// ...
}
The question arose when I came across the LoadableComponent design pattern, as Selenium already provides an abstract class for such components, thus making the first inheritance-based solution unfeasible.