Asad Iqbal
Asad Iqbal

Reputation: 3321

What should be the criteria for creating a new type of PageObject

If a button is optionally shown on a page (or part of page), does it qualify that part to be represented as two different PageObjects, where one PageObject provides methods to interact with the button while other PageObject does not? Or, should it be one page with a method which can throw an exception when the Button is not rendered.

What will be a maintainable solution - because in future releases the button may start appearing in both cases or the functionality may totally change.

Upvotes: 0

Views: 88

Answers (1)

ekostadinov
ekostadinov

Reputation: 6950

In this case

the button may start appearing in both cases or the functionality may totally change

possible solution can be - Transporter design pattern. It's basically - navigation that aggregates reused page objects in one external object. Also centralizes the navigation control in the tested system according to the test requirements. This object encapsulates logic associated with the implementation of navigation within the tested system. Thus the problem of business logic does not interfere with the navigation within the system.

I think that Composite Page Object is acceptable and

maintainable solution

in both cases. Since It will allow you to structure your Page objects in a more “object-oriented” way by separating sub objects that can be reused on different pages and include them into the parent object. Consider this example:

enter image description here

Further reading about GUI automation patterns.

Upvotes: 2

Related Questions