premganz / SeleniumPageObjects

An implementation of the Page Object Pattern in Selenium along with a bunch of other features like KeyWords for oft used Webdriver calls, driver lifecycle management, effective logging and Test Script Templates
Other
2 stars 1 forks source link

Cross Cutting Tests Across Pages #23

Closed premganz closed 9 years ago

premganz commented 9 years ago

There are some cases where validation is required across pages, in a context. For instance of headers and footers. It was assumed that validation done once during the initial tests could cover this, but there are cases where one or two pages might get missed out in a cross application update.

  1. SuperClass Method a. Page interface to have a validate() method. b. The Implementing projects would have suitable superClasses for sets of Pages that have different implementations of the validate() method.
  2. Validator method: a) A PageValidator interface would be created with a method validate() b) So what was done was to empower the Factory to add Validators to pages based on regex c) The Pages can receive Validators and store them. d) The validator.validate() method will be called on the setState() method and a navException would be thrown on failure.

The advantage of the second method would be that the validator can be configured into the factory at the time of building the SimpleScriptXXXX that would extend the JUnitScript. This allows for using all the pages with a different type of validator based on environment variable. For instance if the environment variable is "ACCEPT", one can check the version as "1.2" on each page.

premganz commented 9 years ago

Implemented in 1.2.5 in validator method

premganz commented 9 years ago

Mode some more changes, in the same release 1.2.5 , it is not wise to have the setState do the validation everytime, for every navigation across a page, it would be a waste.

So made the isValid(kw) method explicit on the Page and the validation itself is now called as the PageLayoutValidator.

This isValid is called from the kw.checkPageLayout* set of methods. Think that is fair enough

premganz commented 9 years ago

The isValid() is causing confusions, it works only when the checkPageLayout is used, whereas a more proper use case would be to validate it when the page loads. So validator interface now has two methods-> validate(kw) and validateOnLoad(kw). The Page no longer has validate() method, instead you will need to pull out the validator and call validate()

The Navigation library is modified to use validateOnLoad for every navigation . So its integrated with the navigation.