Showing posts with label QTP Scripts. Show all posts
Showing posts with label QTP Scripts. Show all posts

Tuesday, August 7, 2012

Keyword Driven

Object:

         As very simple to describe about object, "Each and everything that we seeing in Application is called an Object", The identified objects are been stored in object repository,

                          QTP --> OR --> Application

        When the QTP play back the recorded scripts, At first QTP will look for objects that we stored in the repository, "Object Repository" is the place where it holds its properties and its values, Here we can store all the object information's which is available  in the application, and it acts as a interface between QTP and Application

Steps to go for Object Repository:

1. Open QTP
2. Click on "Resources" menu
3. Click on "Object Repository" (Ctrl+R)

After the above steps, Click on "Add Objects to local" Menu



















In above screenshot i just captured the all objects of "www.google.co.in", Here the selected Test Object is "Google" the object Properties of the google is the same highlighted in Right side of the page,

Name: Google
Class: Browser
Repository: Local (Stored in Local system)

By having the above object properties we can generate the script without recording, since the captured object is get stored in local,

Browser("Google").Page("Google").WebEdit("q").Set"QTP"
Browser("Google").Page("Google").WebButton("Google Search").Click

the above script will "Google Search" the word "QTP" once it get playback from the "Object Repository"

Monday, August 6, 2012

Generation of Scripts for Windows Application

Record and Playback:

Dialog("Login").WinEdit("Agent Name:").Set "admin"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

Above scripts are recorded for default "flight reservation" free windows application available in QTP,

Variation of scripts for Windows and Web:

There are some difference in scripts that we can see here for recording windows and web application,
for web application we are using the "object" of the text box as WebEdit (" ") and for button "WebButton"
for windows application the "object" of the text box here we used as WinEdit(" ") and for button "WinButton".

By keeping the above recorded scripts to bring up the same for the basic framework level we need to implement some validation codes to run the recorded scripts once giving play back in QTP,

Systemutil.Run(""C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4b.exe")
Dialog("Login").Active
Dialog("Login").WinEdit("Agent Name:").Set "admin"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

The above code will give the best output while QTP play back the scripts.

Dialog("Login").Active -  Indicates the login window should active to display whenever the user playback the scripts

Sunday, August 5, 2012

Generation of Scripts for Web Application

Record and Playback:

Browser("name of the application in the browser").Page("name of the page in the browser").object("name of the object identified").Operation

So, This is the basic steps of how QTP generates the scripts while Recording.

The above scripts will be play back once the browser is in default open state, If the browser is closed and you need to play back the script automatically in qtp just you need to add the below script,

Systemutil.run"C:\Program Files\Internet Explorer\iexplore.exe","www.google.co.in"
Browser("name of the application in the browser").Page("name of the page in the browser").object("name of the object identified").Operation