Pages

Monday, July 1

Descriptive Programming in QTP - Part 1

Hello Friends,
In this series of post, we'll learn in detail how to use Descriptive programming (DP) in QTP.

Before starting DP, let's understand the basics about object identification. There are two ways, QTP uses to recognize the objects present in your application.

1. Object Repository (OR)
2. Descriptive Programming (DP)


What is Object Repository (OR)?

OR is the simple and default way of object identification in QTP. Object Repository is a storage place of QTP, where  properties and values of every object are stored. While you record on application, all the objects you click/interact, are stored in Object Repository.

During the play back QTP use this OR to identify the object on which the action is to be performed.


What is Descriptive programming (DP)?

We'll use DP when we want to bypass OR. Descriptive programming is used when we want to perform an operation on an object that is not stored in the object repository. This way QTP won’t search for the object properties in the Object Repository, but will take it from the DP statement of your code.

Why use Descriptive programming (DP)?

Everything looks fine while automating test using OR, then why should I use DP?


Well, there might be many valid reason to do so. Think about a situation - you want to close all opened browser automatically before you start executing your script. Here OR will not help you to identify an object as it is not possible to store all the opened browser objects into OR. Make sense?



I am not very good in vbscript. Is it mandatory to learn vbscript explicitly to write DP?

No. Not at all! Its not mandatory, but yeah.. recommended. For basic operations and starting with DP, this post will guide you.
Although, for advanced operations i.e. using COM, AOM, complex frameworks etc. vbscript knowledge is the key.

Okie guys! Now, let's start writing DP!

Types of Descriptive Programming (DP):

DP can be written in two ways..

1. Static (by provide the set of properties and values directly)
2. Dynamic (by creating description object)


Static:

- In Static method of DP, we provide the set of properties and values directly in a single line, in form of the string arguments.

Here is the format/syntax of DP..
object's Class Name("property name:=property value")


Exmp 1: webbutton(“Name:=Google Search”)

object's Class Name = webbutton 
property name = Name
property value = Google Search


Exmp 2:- Browser(“google”).page(“google”).webbutton(“name:=Google Search”,”type:= Submit”).click

In above statement, Browser(“google”) and page(“google”) are written using OR. And webbutton(“name:=Google Search”,”type:= Submit”) is written using DP. 


Please note that we can write multiple set of properties and values in any DP statement.

Examples:
webbutton(“name:=Google Search”).click
webbutton(“name:=Google Search”,”type:= Submit”).click
webbutton(“name:=Google Search”,”type:= Submit”,"x:=301").click


TIP: A statement can be written by combining OR and DP approach, but OR can be used only before DP. once you use DP, you can't write OR after it.

Correct: Browser(“google”).page(“google”).webbutton(“name:=Google Search”,”type:= Submit”).click


Above statement is correct because DP(webbutton(“name:=Google Search”,”type:= Submit”)) is written only after OR(Browser(“google”).page(“google”)).

Incorrect: Browser(“name:=google”).page(“title:=google”).webbutton("Google Search").click


Above statement is incorrect because DP (Browser(“name:=google”)) is used before OR.




We can get the all properties and values of object using Object Spy.



Okie!! Let me add one more point here. You can use variable also in Descriptive Programming (DP)!! Here we go...

Dim var_name
var_name = "Google Search" 
webbutton(“name:=” & var_name).click

Key Points:

  • Object Repository (OR) and Descriptive Programming (DP) are two ways, QTP uses to recognize the objects.
  • These two ways are also known as Object Identification techniques.
  • Descriptive Programming (DP) can be done in two ways - Static and Dynamic.
  • A statement can be a combination of both OR and DP approach
  • OR approach can be used only before DP. once you use DP in a statement, you can't write OR after it.
  • Properties and values of object for DP are captured using Object Spy.
  • Variable also can be used for property values in DP.


In next part of post, we'll discuss another type of DP - Dynamic.

In case of any queries, please post your comments.

Sunday, June 30

PMP Certification - Summary of new changes in PMBOK 5 - Part-1



Hello friends!!


On this page, I'll start a series of posts on PMP certification based on PMBOK 5. 

Hope you are aware that pmbok has been changed/updates recently. Here we will very briefly have a look on the key points/changes in new PMBOK 5. If you are planning to go for PMP certification, below information will be useful-


-    PMBOK 5 has been released in Jan 2013 and available in market to purchase.

-    PMBOK 5 will take effect on 31st July 2013 (for Exam purpose). If you are planning to sit for exam ON or AFTER 31st July 2013, it’ll be based on PMBOK 5.



PMBOK 5 comes with few changes (not major), which are very briefly described in this post. These changes makes PMBOK 5 even more easier and simple to read/understand.



In PMBOK 4 – There was 5 Process Groups + 9 Knowledge Areas + 42 Processes

In PMBOK 5 – There are 5 Process Groups + 10 Knowledge Areas + 47 Processes



In Brief:- 


1 Knowledge Area has been added

-          Stakeholders Management


5 new processes have been added

-          Plan Scope Management

-          Plan Cost Management

-          Plan Schedule Management

-          Plan Stakeholder Management

-          Control Stakeholder Engagement



Also, few process names have been modified. 



 

Below diagram shows all the 47 processes and 10 knowledge areas in PMBOK 5.







I'll soon start posting detailed posts on common points like "How to clear PMP", "What kind of preparation/study plan required", "What study materiel is best" etc.

I encourage you to post your comments and let me know what you want me to include in the series of posts.

Saturday, February 16

Difference between Action, Procedure, Function and Sub?

Hello Friends!

I believe that many QTP newbie’s are confused about Action, Procedures, Function and Subs. Am I right?

No worries! Here we are going to discuss all of them in detail to eliminate all the confusions!

In QTP, there are two ways (on broad level); we can break up the code into logical units. Logical unit is nothing but a 'Piece of code' or ‘a series of VBScript statements’, to perform specific activity in QTP. These two ways are -

1. Actions - specific to QTP
2. Procedures - vbscript provided


Okie.. but what about Functions and Subs? Wait guys! we'll come there.

We know that we use vbscript as scripting language in QTP. (To read about vbscript, Click Here>> )

VBScript has two kinds of procedures: Sub procedure and Function procedure

So, in brief, its goes like this..


1. Actions
2. Procedures
   2.1. Subs/Subroutine
   2.2. Function

Now we know that Action and Procedures are the two things. Procedure is further devided in two types - Function & Sub.

Feeling batter? Great!!

So, Lets start with actions..

1. QTP Actions:-

Action is specific to QTP and not the part of vbscript. Every QTP test has at least one Action(default name is Action1). 
Action can have an object repository associated with it. Action can return multiple values in form of 'output parameters'.

2. Procedures:
2.1. VBScript Sub Procedures:-

A Sub procedure:

  • is a series of statements, enclosed by the Sub and End Sub statements
  • can perform actions, but does not return a value
  • can take arguments
  • without arguments, it must include an empty set of parentheses ()

Sub mysub()
  Print "my Sub Procedude"
End Sub

or

Sub mysub(argument1,argument2)
  Print "my Sub Procedure"
End Sub

How to call Sub Procedures:

To call a Sub, you will use Call statement by enclosing arguments (if any) in parentheses.


The Call statement is not necessary to call a Sub, but if you want to use Call statement (Recommended), you must enclose arguments (if any) in parentheses.

Call mysub(argument1,argument2)

You can call a Sub without using Call statement as well, but not recommended.

mysub argument1,argument2


2.2. VBScript Function Procedures:-

A Function procedure:


  • is a series of statements, enclosed by the Function and End Function statements
  • can perform operations and can return a value
  • can take arguments that are passed to it by a calling procedure
  • without arguments, must include an empty set of parentheses ()
  • returns a value by assigning a value to function name itself

Function myfunction1()
  Print "my fuction1"
End Function

or

Function myfunction2(a,b)
  myfunction2=a+b  'assign value to function name
End Function


How to call Function Procedures:

Call myfunction1()    'calling 1st function, without any return value




abc=myfunction2(argument1,argument2)  'calling 2nd function, with a return value

Here you call a function called "myfunction2", the function returns a value that will be stored in the variable "abc".

Hope all your confusions are gone! But if you still have any doubts, please post your comments!