? QA Design Gurus: Eleven Web UI automation best practices for better results

May 10, 2016

Eleven Web UI automation best practices for better results

A few best practices for Web UI automation:

1)Having better Setup and Cleanup code

                Make use of better and stable Setup and cleanup that executes before and after the test execution respectively. This helps to avoid most of the dependency issues and provide robustness to your tests. As a example making use of REST or SOAP services to as setup and cleanup code will ensure the stability of the tests.

2)Identifying an element with stable property

                With the adoption of agile methodology and Cloud based applications most of the Web UI changes frequently to attract customers. This results in failure of Automated tests. To overcome the issue, Identify the element in the UI with more stable property. Using Dynamic ids are tag index will result in instability of the tests.

3)Making use of Reusable components

                Consider making the reusable steps as Utilities or functions, which results in faster development and maintenance of tests. Making the fix failure in the function results everywhere it is being used. Initial days of Automating a UI may not have utilities or it is difficult to decide whether to make set of actions as utility or not. Moving to further development utilities grows in incrementally and adds value to the development. Reusable components should be thoroughly tested since it will be used by multiple tests.

4)Better usage of Wait Statement

                Identifying an element may fail since the finding logic may have executed before the entire UI is loaded. So Simply using Wait statement may not be wise idea. Better to wait for a particular element in the UI rather than standard Wait statement. This ensures that following steps will be executed only after the UI is loaded.

5)Improving the readability of Tests

   Readability can be improved in many ways, below are listed few:

·         Keep the tests simple and short.
·         Name the test case such that it will reflect the purpose.
·         Provide better and meaning full names for the Elements in Element Repository.
·         Identify Element in UI with minimum set of properties.
·         Provide better name to step.

6)Consider different ways of identifying an element

                Conventional way of identifying an element using Element property directly may not work or there may be multiple elements with same property in such cases, trying the alternate ways may lead to better results below are few:

·         XPath: This can be used to find the relative location of an element if the element is not unique.

·         JQuery : We can perform complex browser actions using JQuery where conventional methods may not work.

·         Parent–child: Sometimes child element may not be unique, considering parent tag and navigating to child may result in uniqueness and stability.

7)Maintain Element Repository Globally

Make sure that Elements in the element repository is unique and reuse where ever required this makes easy maintenance and fixing of the test. Fixing a single element will be reflected in all the places it has been used. Though this have negative impact such as duplicate entries of elements, searching an element this can be overcome by following some conventions for the Elements.

8)Make use of services in UI Automation where UI Automation is not mandatory

Can make use of services like REST or SOAP which can perform some action that is not mandatory to test using Automation tool. This makes tests shorter and increase reliability, since the services are more stable than UI.

9)Scenario based testing over functionality based testing

Develop the test based on the scenarios that will cover the multiple functionality of the elements. Unit tests will ensure that basic unit part of the code is working fine hence focusing more on the scenarios that covers multiple functionalities will result in wider coverage of tests.  

10)Generating Custom Report for better debugging

Make use of Report generated by the tools if found that is difficult to debug. Develop the Custom report such that it will ease the debugging time.

11) Keep tests to a reasonable length


As a fact that long tests takes more debugging time considering shorter ones. It is better to keep the tests short and simple.


No comments:

Post a Comment