Page Object Pattern v/s Separating elements from behavior

This is one of the most common issues that you face while designing a Selenium Webdriver test automation framework.

Technique 1:
Something that you will see being either prescribed by people who have been doing automation for long or have used in automation tools earlier ( like QTP/TestComplete). Create page elements/locators class to store all elements and a separate page object class for the behavior of elements in that page.

Technique 2:
In contrast to the above idea here we use just one page object class to store all the elements and methods for that page. Validations and test flows reside outside the page object class.

I guess as an automation architect the only question I always have is
"Which design is easier to manage and maintain?"

A combination of the two approaches is what makes an hybrid maintainable framework. Have separate page elements but store them in a Java properties file. Have a page element class or a Business process class for behavior of each flow. Further have actions and keywords that facilitate a layer of abstraction over the Selenium API being used as the core engine of the framework.
I like the idea of locators in properties file as you can make changes w/o having to modify the source code. Similar to application config files to specify settings & global parameters.

Pros and Cons
Advantages of this approach is that whatever you use (Properties files/XML files/JSON files) Business Analysts/Manual Testers or any non-programmer can adjust tests to changing circumstances 
On the flip side programmers who are the only ones who can understand the test logic don’t have immediate access to details that bind the app to the test.

Happy Testing!


Popular posts from this blog

XPATH for IE / internet explorer

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath