Page Object Pattern Web Testing - Parsh
The main lesson is: Use the Page Object Pattern as it works well:
- Two distinct styles of test framework, the test, and the page object. The tests are therefore decoupled from the app implementation.
- The page object should act as the interface to the app allowing access to all elements. It should model all the HTML pages. Any changes in the application HTML should only require a change to the page object code.
- The tests use Domain Specific Language and have little knowledge of the underlying implementation
- Static page checks should be performed once by the app, ideally in the page object
- Make use of XPATH as it is very powerful and is closely related to the HTML
- Consider OO tests so that we can lever the power of encapsulation (e.g. code completion for page elements and actions), inheritance (e..g for common page elements such as headers) and polymorphism (e.g. for reducing custom code)
- Build reporting into the framework and include screenshot taking. Ideally the report(s) should be based on data generated by the test e.g. in XML or a database
- Provide a customer data driven test interface(e.g. spreadsheet) for customer specific tests.
- Consider using a well established programming language (such as Java, Ruby, or C#) as it will come with a rich library set and lots of online advice
- Consider whether non-JS needs to be supported as this will influence your technology decision
- Test should be 'annotated' to allow grouping so that suites of tests can be defined, such as , Smoke, Integration, UAT,Performance etc
- Create utilities where possible to avoid unnecessary code
- Use ENUMs to define lists which can then easily be iterated over
- Always test the app, and never internal representations, otherwise your tests are not testing the app
- Reload the Page Object whenever you navigate to the app page and perform a static check on the Page ID to ensure the flow is as expected
- Run cross browser tests using a VM framework
- Run Smoke tests on all code checkins, and all tests on a nighlty basis