November 4, 2010

Improving the Maintainability of QA Wizard Pro Scripts with Comments

Helix ALM
After recording a QA Wizard Pro script, the purpose of my recorded actions is still fresh in my mind. So I quickly add comments above code before I forget what I've done. When I have to revisit my scripts months later, those comments really come in handy. But what happens after I record a long script? I usually get lazy and don't add as many comments after recording. There are so many steps and actions that I forget what half of them do. Alternatively, I change my behavior to only record small scripts, making my recording efforts less efficient--but hey, at least I can remember everything I did and comment appropriately. QA Wizard Pro 2011 adds a simple new feature that I find surprisingly helpful.  While recording, you can add comments. Recording Dialog featuring new Comment button. To add comments while recording, click the Comment button on the Recording toolbar, type your comment, and then click OK. Keep it up throughout your record session, describing what you're about to do. The end result will be a script that's much easier to understand.
'Navigate to pie selection.
Window("m").Button("goToPies").Click()
'Verify pies can be checked and unchecked.
Window("w").ListBox("pies").Item("Apple Pie").CheckBox(1).Set()
Window("w").ListBox("pies").Item("Apple Pie").CheckBox(1).Checkpoint("Checked", True)
Window("w").ListBox("pies").Item("Apple Pie").CheckBox(1).Clear()
Window("w").ListBox("pies").Item("Apple Pie").CheckBox(1).Checkpoint("Checked", False)
Adding comments while recording is a simple discipline that will dramatically improve the quality and maintainability of your scripts.