Qtp Descriptive Programming 11200
-
Upload
techgajanan -
Category
Technology
-
view
620 -
download
2
Transcript of Qtp Descriptive Programming 11200
![Page 1: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/1.jpg)
DP 101 in 60 simple slides
www.AdvancedQTP.com
![Page 2: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/2.jpg)
What is DP?
DP stands for
Descriptive Programming
![Page 3: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/3.jpg)
But what IS DP?
It’s a cool way to work without QTP’s Object-Repository (OR)
![Page 4: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/4.jpg)
Why would I want to do that?
![Page 5: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/5.jpg)
Many reasons
![Page 6: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/6.jpg)
You have to
Functions & Recovery scenarios work with different actions
Different actions = Different ORs
![Page 7: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/7.jpg)
Do I know you?
Can’t be sure…
![Page 8: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/8.jpg)
You have to
Can’t record certain objectsAuto-hide panels
Objects with changing hierarchies
Nested inner-objects, Sub menus
![Page 9: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/9.jpg)
Hold still, damnit!
Even when you think you got it, all the properties turn out null
![Page 10: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/10.jpg)
Simplicity
Why kill a fly with an atom bomb?
No need to use the OR for every one-time click button in the application
![Page 11: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/11.jpg)
And,You can do VERY cool things with DP
![Page 12: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/12.jpg)
OK, bring it on
![Page 13: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/13.jpg)
First, we need to better understand the Object Repository
What the OR is
How does the OR work
![Page 14: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/14.jpg)
I thought DP is all about NOT using the OR…
![Page 15: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/15.jpg)
Well, yes, but under the hood, DP & the OR work the same way
To understand the OR, is to understand DP
![Page 16: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/16.jpg)
What is the OR?
![Page 17: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/17.jpg)
A mysterious beast that records objects, in order to use them later
![Page 18: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/18.jpg)
What is to record an object?
Write down how to identify it
![Page 19: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/19.jpg)
Who are you?
=How can I identify you?
![Page 20: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/20.jpg)
Identification is done with
properties and values
![Page 21: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/21.jpg)
Who are you?
=Your height = 400
Your title = “NotePad”
You are visible (=True)
![Page 22: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/22.jpg)
So, What IS the OR?
Collections of properties & corresponding values
Each collection represents an object
No mysterious beast here
![Page 23: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/23.jpg)
OK, So what IS DP?
DP is a way for specifying the properties & values without using the OR interface
No mysterious beast here, either
![Page 24: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/24.jpg)
OK, I get it, there’s nothing more than properties and values
Can we get on with it?
![Page 25: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/25.jpg)
How do I actually use DP?
There are two ways
![Page 26: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/26.jpg)
1Throw the properties and values
straight into a command
![Page 27: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/27.jpg)
It’s the good old syntax you know, except the string between the () is not the OR name.
It’s the property:=value identification string
![Page 28: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/28.jpg)
That’s kinda restrictive
What if I want to use multiple identification properties?
![Page 29: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/29.jpg)
No problem:
VBWindow(“height:=400”, “title:=New Document”).Maximize
You can use as many properties as you like
![Page 30: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/30.jpg)
All fine and well, but what if I want to use regular expressions?
![Page 31: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/31.jpg)
No problem:
VBWindow(“title:=.*Document.*”).Maximize
ID strings are automatically interpreted as regular expressions
![Page 32: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/32.jpg)
2Throw the properties & values into a description object, and throw IT into
the command
![Page 33: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/33.jpg)
Here also, all the values are interpreted as regular expressions. To turn it off, use
oDesc(“Property1”).RegularExpression = False
![Page 34: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/34.jpg)
Method 1 is faster, best used for one or two commands, tops
![Page 35: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/35.jpg)
When you want to execute multiple commands on an object, method 2 is a better choice by far
(allows one-time definitions, multiple uses)
![Page 36: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/36.jpg)
You can use DP with OR
VBWindow(“OR”).VBButton(“text:=OK”).Click
Or (when oDesc is a description object):
VBWindow(“OR”).VBButton(oDesc).Click
![Page 37: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/37.jpg)
But, you can only start from OR, and move to DP
So this will not work:
VBWindow(“title:=notgood”).VBButton(“clickme”).Click
![Page 38: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/38.jpg)
And that’s about it
You can use each of the methods (or combine them), and you’ll be able to use objects that are not in the OR
![Page 39: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/39.jpg)
You said I could do really cool stuff with DP!
![Page 40: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/40.jpg)
Right you are
We’ll cover some of the more popular tricks and tips
These examples are only the tip of the iceberg. Play with them and see the true power of DP
![Page 41: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/41.jpg)
The power of the string
DP is nothing more than simple strings
We can do such interesting things with strings…
![Page 42: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/42.jpg)
The power of the string
Say we got an app with 4 checkboxes, check0, …, check4
We can set all of them with a nice simple loop:
![Page 43: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/43.jpg)
The power of the string
Very complex identification tasks can be done via strings manipulation
Try different variations for yourself
![Page 44: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/44.jpg)
Solving double objects
When QTP finds two object which match the same description, it freezes
This kinda sucks
![Page 45: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/45.jpg)
?
![Page 46: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/46.jpg)
DP has a magic property: “index”, which allows us to tell the double objects apart
Index is a zero-based counter
![Page 47: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/47.jpg)
All is well
![Page 48: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/48.jpg)
Getting objects collections
This feature is so cool, deserves a title on its own
![Page 49: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/49.jpg)
THE coolest thing you can do with DP, is to get a
collection of all the objects that math an identification
![Page 50: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/50.jpg)
I don’t know who you are, or how many are you, but I want to mark all of you!
Regular DP won’t help - Don’t know how to identify each checkbox
![Page 51: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/51.jpg)
Object collections to the rescue!
Step 1: define a description object
![Page 52: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/52.jpg)
Object collections to the rescue!
Step 2: get all matching objects
![Page 53: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/53.jpg)
Object collections to the rescue!
Step 3: Use the collection
oChildren now holds a collection of all the checkboxes
So the first checkbox is accessed by: oChildren(0)
![Page 54: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/54.jpg)
What can we do with it?
Anything we want
![Page 55: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/55.jpg)
Example for common uses
Mark all Checkboxes
Mark all checkboxes with a certain property (even RO)
![Page 56: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/56.jpg)
The possibilities are endless
Randomly input fields
Input only mandatory fields
Zero maintenance (new fields are added automatically, blind to UI changes)
Select object which match complex identification criteria (write custom if filters)
The list goes on and on…
![Page 57: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/57.jpg)
OK, this is indeed cool, but it only gets us the inner controls of a given window.
Can we also get the application’s top level windows?
![Page 58: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/58.jpg)
Sure
![Page 59: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/59.jpg)
So, With DP we can work with no OR
Sometimes we have to use it
Other times it’s just more fun and useful
DP also throws in a lot of extras that make it an inseparable part of good QTP automation
Taste it, Experience it, Learn it, Use it, Love it
It’s worth your while
![Page 60: Qtp Descriptive Programming 11200](https://reader034.fdocuments.net/reader034/viewer/2022042607/55852387d8b42ada748b4f0a/html5/thumbnails/60.jpg)
And that was DP in 60 slides