views:

781

answers:

2

I am experimenting with using QTP for some webapp ui automation testing and I was wondering how people usually write their QTP tests. Do you use the object map, descriptive programming, a combination or some other way all together? Any little code example would be appreciated, Thank you

+3  A: 

Hi Josh,

Here's my suggestion.

1) Build your test automation requirements matrix. You can use samples from my blog

http://automation-beyond.com/2009/06/06/qa-test-automation-requirements-usability/

http://automation-beyond.com/2009/06/07/qa-test-automation-requirements-usability-2/

http://automation-beyond.com/2009/06/10/qa-test-automation-requirements-5-maintainability/

http://automation-beyond.com/2009/06/08/qa-test-automation-requirements-robustness/

http://automation-beyond.com/2009/06/09/qa-test-automation-requirements-scalability/

2) Choose your automation approach

3) Write your testing scripts according to the approach you chose

Note. QTP Repository way or Descriptive Programming belong to GUI recognition part of front-end functional test automation. They matter in terms of robustness and maintenance. Technically, it's nearly the same. In both cases you should understand GUI recognition concept well, or you will have problems no matter the approach.

  • You can store GUI object recognition properties in XML-like data structure and map the record to an English-like name. Whenever the original object's properties change, you update your record in repository, while a code still refers to a mapped name.
  • Or you can address GUI objects by directly putting same recognition properties into a function call. Whenever the original object's properties change, you have to do code change. But you don't have to maintain extra files along with your scripts.

A good framework should support both GUI-mapped and descriptive programming notations by operating at object reference level. I.e. you should keep object recognition and object interaction tasks separate.

Note that depending on context Descriptive Programming notation may slowdown performance of your scripts and it always demands extra maintenance effort while in other cases using Object Repositories only may lead to unwanted duplication of objects' descriptions or it may limit recognition of dynamically changing GUI.
I illustrate some points made above in the following article: A little QTP performance test: Object Repository vs. Descriptive Programming

Straight code examples (for a practical automation I recommend GUI Function Wrapping).

Descriptive programming - addressing objects by physical description properties.

Dim sProfile
sProfile = "Guest"

Set objWebParent = Browser("title:=Select Profile").Page("title:=Select Profile")
Set objWebObject = objWebParent.Link("text:="&sProfile) 
boolRC = objWebObject.Exist(0) 
If Not boolRC Then
'error-handling
End If
objWebObject.Click

Addressing objects by mapped GUI names

Browser("Select Profile").Page("Select Profile").Link("Guest").Click

Thank you,
Albert Gareev
http://automation-beyond.com/

Albert Gareev
Thank you for your post Albert. From what I gathered you would suggest a hybrid approach of Object Map with descriptive programming when necessary? Nice site by the way, I would have to say robustness is the most annoying part of ui automation.
Josh Harris
Hi Josh. Yes, I would strongly recommend having library functions that receive object reference as a parameter. When calling from outside you'll have a freedom defining objects both as mapped and through descriptions. Yes, making your scripts robust is really challenging but it should be a part of the framework and not in the test logic.
Albert Gareev
The "automation approach" link in Albert's post is one of the best summaries I have seen regarding this topic. Nice stuff.
TheBlastOne
If you design your Functions Library in a way that you have functions wrapping GUI functions, and those wrapper functions take each GUI object as parameter, than for those wrapper functions it is not important weather you pass object names from Object Repository, or instances of Description Objects. So with proper library design you can use both OR and DP.
yoosiba
+1  A: 

Hi Josh,

I know I am late here, and you must already have what you are looking for, but I wanted to provide my inputs as well for anyone visiting this topic.

I generally never use OR, unless I encounter an environment where Descriptive Programming is a no-go. Just recently, I worked with a Mainframe Front-End GUI application that has absolutely no naming convention for objects. If you choose to use Descriptive Programming with such an application, the only way to work with its objects would be through Index or Location Ordinal Identifiers, which is not the best course of action considering 100's of objects in each pane.

So, the answer to your question really depending upon the environment and your experience with OR and DP. Most people I have worked with at my job, and on online communities prefer to work with Descriptive Programming whenever its feasible. However, I have also seen people work wonders with OR.

I have a few code samples, but, unfortunately, they are deal with Descriptive Programming. For instance, the following article talks about creating modular VBScript classes to divide application's functionality into small manageable components:

http://relevantcodes.com/qtp-using-classes-as-test-modules-i/

Similarly, this article shows how Descriptive Programming can be used to verify multiple properties of target objects through a single block of code:

http://relevantcodes.com/qtp-verify-multiple-object-properties-an-elegant-approach/

Also, a demo framework is also available for you to view here:

http://relevantcodes.com/relevantcodes1one-qtp-automation-framework/

The framework is built completely on the principles of Descriptive Programming, but in the next release, some functionality will be added that will enable users to work with ORs as well.

Thank you,

Anshoo Arora

(Thanks for linking to the original articles, Motti)

Anshoo Arora
I assumed DP would be the method of choice when possible. I just was not quite sure if QTPs OR system was really good or not. Currently I use TestPartner and completely avoid its OR system. Thank you for the info Anshoo.
Josh Harris