Sunday 5 June 2016

Page Object Model


           Once you start with automation, a word you will constantly get bombarded with is  ‘Framework' which is a very generic term.  Wiki defines a Test  Automation Framework as an integrated system that sets the rules of automation of a specific product. This system integrates the function libraries, test data sources, object details and various reusable modules. The article has also listed various approaches for designing test automation framework, sadly people categorize them as automation frameworks without understanding that it is just approach to design test automation. Approach of automation framework that one should choose/take must be depends upon the need of AUT.
          Similarly, many folks misunderstood or I am not sure why they call Page Object as framework. It is NOTa framework, it is a Design Pattern which has many advantages. Though there are many resources available on internet on how to implement page object model, very few of them mentions below rules.

Basic rules for getting the desired maintainability of your test code :-
1.      Page objects themselves should never make verifications or assertions. This is part of your test and should always be within the test’s code, never in an page object. The page object will contain the representation of the page, and the services the page provides via methods but no code related to what is being tested should be within the page object.
2.      There is one, single, verification which can, and should, be within the page object and that is to verify that the page, and possibly critical elements on the page, were loaded correctly. This verification should be done while instantiating the page object.
3.      A page object does not necessarily need to represent an entire page. The Page Object design pattern could be used to represent components on a page. If a page in the AUT has multiple components, it may improve maintainability if there is a separate page object for each component.
4.      If you have WebDriver APIs in your test methods, You're Doing It Wrong. [This is what point 1 is all about. ] -- Simon Stewart.


Ref:- http://www.seleniumhq.org/docs/06_test_design_considerations.jsp#page-object-design-pattern



0 comments:

Post a Comment

Copyrights held by Amol Chavan. Powered by Blogger.