Sep 15 2009 03:05:28 AM Posted By : rajasankar
Comments (0)

Maintaining scripts is an important task in UI automation. Some times, it may be difficult to do. However, if we separate script flow and actual actions, we may able to maintain the scripts without any issues even the UI changes.

The formal approach.

Here is the steps to create for a test script w.r.t to QEngine

1. Create New Suite named as Test
2. Create New module in that suite if needed
3. Create New Script named as TestScript
4. Record the steps in TestScript.
5. Playback when needed.

Looks cool. Say, we have 100 scripts in that Test Suite. Playback is not an issue. Assume that one element changed in the UI. Now, we need to check and edit all the 100 scripts. This will neutralize any gains made using test automation.

Here is the new model

1. Create New Suite named as Test
2. Create python file for UI functions named UIFunctions.py
3. Create python file for script flow named ScriptActions.py
4. Create New Script named as TestScript
5. Record or use export mode for recording the scripts. Create functions using recorded actions. Store the functions in UIFunctions.py
6. Call the functions needed in ScriptActions.py.
7. Call and import the script flow in TestScript.
8. Playback.

In this approach, if anything changes we need to modify in two files. Let see this with examples.

Content of UIFunctions.py

Code:

from Framework import *

def clickthisbutton():
setLastWindow()

def clickthislink():
setLastWindow()

def function1():

..........
.........
.....


Content of ScriptActions.py
Code:

from UIFunctions import *

def Script01():
clickthisbuttion()
clickthislink()


def Script02():
clickthislink()
clickthisbutton()


def Script03():


def Script04():

..........
.......
.......


Content of TestScript01
Code:

from ScriptActions import Script01

Script01()

Content of TestScript02

from ScriptActions import Script02

Script02()
.......
.....




In this approach, there is no need to edit the script files,even though they can be editied in the text editor. The files has .wcs extention and located in /QEngine Home/projects//webscripts/ folder.

If the UI changes, you need to either edit UIFunctions.py or ScriptActions.py or both. If needed you can use an macro to replace the changed parameter.

This approach combines the advantage of Scripting with Playback. If you wish, you can use the texteditor or IDE to edit the python files.

Rajasankar
rajasankar at zohocorp dot com

No one has commented yet! Be the first one to comment!

Post Comment