Qtp Descriptive Programming 11200[1]

Embed Size (px)

Citation preview

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    1/60

    DP 101 in 60 simple slides

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    2/60

    What is DP?

    DP stands for

    Descriptive Programming

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    3/60

    But what ISDP?

    Its a cool way to work without QTPs

    Object-Repository (OR)

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    4/60

    Why would I want to do that?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    5/60

    Many reasons

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    6/60

    You have to

    Functions & Recovery scenarios workwith different actions

    Different actions = Different ORs

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    7/60

    Do I know you?

    Cant be sure

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    8/60

    You have to

    Cant record certain objects

    Auto-hide panels

    Objects with changing hierarchiesNested inner-objects, Sub menus

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    9/60

    Hold still, damnit!

    Even when you think you got it, all

    the properties turn out null

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    10/60

    Simplicity

    Why kill a fly with an atom bomb?

    No need to use the OR for every one-time click buttonin the application

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    11/60

    And,You can do VERY cool things with DP

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    12/60

    OK, bring it on

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    13/60

    First, we need to better understandthe Object Repository

    What the OR is

    How does the OR work

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    14/60

    I thought DP is all aboutNOT using the OR

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    15/60

    Well, yes, but under the hood, DP &

    the OR work the same way

    To understand the OR, is to understand DP

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    16/60

    What is the OR?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    17/60

    A mysterious beast that recordsobjects, in order to use them later

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    18/60

    What is to record an object?

    Write down how to identify it

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    19/60

    Who are you?

    =

    How can I identify you?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    20/60

    Identification is done withproperties and values

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    21/60

    Who are you?

    =Your height = 400

    Your title = NotePad

    You are visible (=True)

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    22/60

    So, What IS the OR?

    Collections of properties &

    corresponding valuesEach collection represents an object

    No mysterious beast here

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    23/60

    OK, So what IS DP?

    DP is a way for specifying the properties & valueswithout using the OR interface

    No mysterious beast here, either

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    24/60

    OK, I get it, theres nothing more than

    properties and valuesCan we get on with it?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    25/60

    How do I actually use DP?

    There are two ways

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    26/60

    1Throw the properties and valuesstraight into a command

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    27/60

    Its the good old syntax you know, except the

    string between the () is not the OR name.

    Its the property:=value identification string

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    28/60

    Thats kinda restrictive

    What if I want to use multipleidentification properties?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    29/60

    No problem:

    VBWindow(height:=400, title:=New Document).Maximize

    You can use as many properties as you like

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    30/60

    All fine and well, but what if I want touse regular expressions?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    31/60

    No problem:

    VBWindow(title:=.*Document.*).Maximize

    ID strings are automatically interpreted as regular

    expressions

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    32/60

    2Throw the properties & values into adescription object, and throw IT intothe command

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    33/60

    Here also, all the values are interpreted asregular expressions. To turn it off, use

    oDesc(Property1).RegularExpression = False

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    34/60

    Method 1 is faster, best used for oneor two commands, tops

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    35/60

    When you want to execute multiple commands on an

    object, method 2 is a better choice by far

    (allows one-time definitions, multiple uses)

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    36/60

    You can use DP with OR

    VBWindow(OR).VBButton(text:=OK).Click

    Or (when oDesc is a description object):

    VBWindow(OR).VBButton(oDesc).Click

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    37/60

    But, you can only start from OR, and move to DP

    So this will not work:

    VBWindow(title:=notgood).VBButton(clickme).Click

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    38/60

    And thats about it

    You can use each of the methods (or combine them), and youll

    be able to use objects that are not in the OR

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    39/60

    You said I could do reallycool stuff with DP!

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    40/60

    Right you are

    Well cover some of the more popular

    tricks and tips

    These examples are only the tip of the iceberg. Playwith them and see the true power of DP

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    41/60

    The power of the string

    DP is nothing more than simple strings

    We can do such interesting things with strings

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    42/60

    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:

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    43/60

    The power of the string

    Very complex identification tasks can be done viastrings manipulation

    Try different variations for yourself

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    44/60

    Solving double objects

    When QTP finds two object which match the samedescription, it freezes

    This kinda sucks

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    45/60

    ?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    46/60

    DP has a magic property: index, which allows us to

    tell the double objects apart

    Index is a zero-based counter

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    47/60

    All is well

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    48/60

    Getting objects

    collectionsThis feature is so cool, deserves a title on its own

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    49/60

    THE coolest thing you can do with DP, is to get acollection of all the objects that math an identification

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    50/60

    I dont know who you are, or how many are you,

    but I want to mark all of you!

    Regular DP wont help - Dont know how to

    identify each checkbox

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    51/60

    Object collections to the rescue!

    Step 1: define a description object

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    52/60

    Object collections to the rescue!

    Step 2: get all matching objects

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    53/60

    Object collections to the rescue!

    Step 3: Use the collection

    oChildren now holds a collection of all the checkboxesSo the first checkbox is accessed by: oChildren(0)

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    54/60

    What can we do with it?

    Anything we want

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    55/60

    Example for common uses

    Mark all Checkboxes

    Mark all checkboxes with a certain property (even RO)

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    56/60

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    57/60

    OK, this is indeed cool, but it only gets us the innercontrols of a given window.

    Can we also get the applications top level windows?

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    58/60

    Sure

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    59/60

    So, With DP we can work with no OR

    Sometimes we have to use it

    Other times its just more fun and useful

    DP also throws in a lot of extras that make it aninseparable part of good QTP automation

    Taste it, Experience it, Learn it, Use it, Love it

    Its worth your while

  • 8/4/2019 Qtp Descriptive Programming 11200[1]

    60/60

    And that was DP in 60 slides