? QA Design Gurus: UI Test Automation
Showing posts with label UI Test Automation. Show all posts
Showing posts with label UI Test Automation. Show all posts

May 11, 2016

UI Test Automation with less dependency on UI development

 As software development is getting more and more agile, the need is to reduce the effort required in the system testing phase and start testing early in the cycle. How can we reduce test effort?  By automating the tests. When can we automate tests, especially UI automation? We need a stable UI and an application ready for the test code development right? Ohhh, does that sound ridiculous?

How can we develop a UI automation suite, when the dev team is not even ready with the UI design, and we don’t have a stable UI to for developing the automation suite? Yes, we can achieve it if we follow a well-structured, layered and loosely coupled automation solution.

The idea here is to separate out the layer of specific actions on the UI from the scenarios and tests. The specific UI actions can only be identified once the UI is ready and stable which can be achieved only later in the cycle. But what about the tests and scenarios, these would be known to us earlier when the requirements are baselined.  The chances of the scenarios and tests to change over the cycle is very less when compared to the UI.

Before we go into the details, let’s look at the anatomy of a typical test suite for UI automation.

A test automation solution will mostly consist of these components as mentioned above either well-structured or layered or mixed up in a clutter. The worst case that I have seen in my experience is that all of these layers are not well separated and there are cross references among these.

A better level of maturity that we can see is where the layers are well organized as below.

This is the most common form of test automation suites than we can see in the industry now. There will be a tests layer at the top which interacts to test data layer either by using the tool capabilities or a custom implementation. The test layer interacts with the scenarios layer which has a high level implementation of scenarios and not a set of detailed actions. The scenarios layer will use the actions layer to realize the actions needed for a scenario. This might look very familiar to all who have done a structured test automation framework. This is good, but would you be able to do the following with this approach.

  1.    Start developing the automation suite before even the UI design is finalized
  2.    Remove any layer without code changes spread across other layers(loosely coupled)
  3.    Spend minimal effort  in the System Testing phase for completing the automation suite and         use the suite effectively to run the tests


In order the achieve this, we need to think of how we can make the solution loosely coupled, easily extendable and maintainable. We can achieve this by Making components/layers  depend on contracts rather thanimplementations Following design patterns wherever appropriate Strictly adhering to design principles and coding standards Design the solution with interfaces to set the contract on which each layers will interact and use a factory pattern to provide the concrete implementation of the components.

So the tests layer only knows the signatures of methods or in fact the contracts it can use on the scenarios to run the test. The scenarios layer knows only about the contracts on action methods. It doesn’t know how the actions are going to be implemented. We can plug in any implementation of the scenarios or actions component to the tests. So the business logic tests can be same for different implementations. Even the test data, whether it be dynamic or static should be abstracted by test data adapter layer which provides the data required for the tests. Tests layer will never know how this data is created or fetched for it



Feb 8, 2016

TTS Tips: Moving elements in Element Repository from frame to its parent page

In the current software industry, web applications have been changing drastically day by day. There is a possibility that the application has frames at initial stages of development and will be removed at later point of development. This poses unique set of challenges during test automation. 

TTS uses global Element Repository concept to store element objects. If the application has frames, the elements inside the frame will be stored in the hierarchy like Page Node --> Frame Node--> Element Node and the elements outside the frame will be stored in the hierarchy like Page Node--> Element Node. 


Element inside the frame:

 


Element outside the frame:

 

 


The TTS execution engine does not use the page node but it uses both frame node if exists, and element node during test execution. Hence, even though element identification logic is same, the test case which has written on old application will not work on new application after removing frames. Unfortunately, we don't have any way from TTS tool which we generally use to automate, to move the elements from frame to its parent page. TTS tool also doesn't allow to delete the element from Element Repository if it used in any one regular step. So the only way from the tool is, delete the corresponding regular step then delete element if it still exists in Element Repository. Now add the new element and corresponding regular step again. If there are one or two then it will be ok but if we have more such scenarios then it will be very tedious to QA to perform those many steps for each time.

One alternative way by which we can move the element from frame to its parent page node is, updating ".tstest" file. Yes, what you have listen is correct. By updating ".tstest" file we can move the element from frame to its parent page node without going to TTS tool UI and run the same test case without deleting and adding same regular step with new element like what I have mentioned above. I hope, you all know that when we create test from TTS tool , the corresponding ".tstest" file will be generated at a specified location. This ".tstest" file has auto generated code by TTS tool so we have to be very careful while updating this file. Updating this file is nothing but updating meta data that will be used by TTS tool to render test.

Below are the steps that needs to be performed on ".tstest" file to move the element from frame node to its parent page node.


1. Open '.tstest' file in Notepad/Notepad++.

2. Go to 'Steps' section. To go to this section search for '"Steps": { ' in '.tstest' file.


3. Go to the step that needs to be update. You can search with the test step description like 'Click on Data Source Groups'.




4. Go to elements section of that step and update Frame value with null.



Before update:

 

After update:

 

If there are minimal elements or test steps that needs to be changed then I will always suggest first approach.