Sunday, December 27, 2009

Retrieve Field/column count of Database Table

Hi ,
Here is the script for finding the number of fields/columns of a Table in MS Access Database.
Dim db
Set db=createobject("ADODB.Connection")x.ConnectionString="DBQ=C:\PROGRAM FILES\HP\QuickTest Professional\samples\flight\app\flight32.mdb;DefaultDir=C:\PROGRAM FILES\HP\QuickTest Professional\samples\flight\app;Driver={Microsoft Access Driver (*.mdb)};DriverId=281;FIL=MS Access;FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\flight32.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
Set RecordSet=db.Execute("Select * from orders")
Set r= RecordSet.fields
msgbox r.count ' Number of the columns in the table 'ORDERS'
For i=0 to r.count-1
msgbox r(i).name ' name of the field/column
Set db=nothing

Import Data from Database Table to Datatable

Hi ,
Here is the script for importing the data from a specific column of MS Access Database Table to Datatable's GlobalSheet.

Code :
Dim db
Set db=CreateObject("ADODB.Connection")
db.connectionString="DBQ=C:\PROGRAM FILES\HP\QuickTest Professional\samples\flight\app\flight32.mdb;DefaultDir=C:\PROGRAM FILES\HP\QuickTest Professional\samples\flight\app;Driver={Microsoft Access Driver (*.mdb)};DriverId=281;FIL=MS Access;FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\flight32.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
Set RecordSet=db.Execute("Select * from Orders")
While (NOT recordset.EOF)
msgbox Datatable("CustomerName",dtGlobalSheet)
Set db=Nothing

Sunday, December 6, 2009

Encrypting a String in QTP

Hi All,

Here we go !!!!

QTP has an utility Object called as "Crypt" object.
As the name implies, the "Crypt" object in HP Quicktest Professional is for encrypting the strings which can only be understood by QTP's "SetSecure" method. "Encrypt" is the only method supported by the QTP "Crypt" object.

syntax : Crypt.Encrypt(Your String)
An example:
msgbox var

The output of the above code would be "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"
As you can see, this string is encrypted which is quite obvious.
Recording on password protected fields automatically encrypts your string for example

Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=Password").SetSecure "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"

Another way , how we can encrypt a string is by using "Mercury.Encrypter"
Set var=CreateObject("Mercury.Encrypter")
Msgbox var.Encrypt("QTP")
Set var=Nothing 'Release the Object reference

Using "Password Encoder".
Navigate to Start-> All Programs-> QuickTest Professional-> Tools-> Password Encoder
Provide your string inside the "Password" field and click on the Generate button. Your encrypted string would be displayed inside the "Encoded String" field.

Wednesday, October 21, 2009

Count number of lines in Text File

Hi ,
Here I am provding the code for finding the number of lines in a Text file.
Code :
Const ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fso.OpenTextFile( "your file path "
, ForReading )
Print "Number of lines: " & textFile.Line


Monday, October 12, 2009

QTP script to Add defect in QC

Hi ,
Most of us would be familiar with logging defects in Quality Center manually.
How about Adding a defect using a QTP script?
Here we go !!!
Script :
Set TDConnection = CreateObject(”TDApiOle.TDConnection”)
TDConnection.InitConnection “http://yovav/tdbin” ‘ DB URL

TDConnection.ConnectProject “TD76″,”bella”,”pino” ‘ Valid login information
If TDConnection.Connected Then

MsgBox(”Connected to ” + chr (13) + “Server ” + TDConnection.ServerName _+ chr (13) +”Project ” + TDConnection.ProjectName )
MsgBox(”Not Connected”)
End If

‘Get the IBugFactory
Set BugFactory = TDConnection.BugFactory
‘Add a new empty bug

Set Bug = BugFactory.AddItem (Nothing)
‘fill the bug with relevant parametersBug.Status = “New”

Bug.Summary = “Connecting to TD”
Bug.Priority = “4-Very High” ‘ depends on the DB
Bug.AssignedTo = “admin” ‘ user that must exist in the DB’s users list
Bug.DetectedBy = “admin” ‘ user that must exist in the DB’s users list
‘Post the bug to DB ( commit )


Tuesday, October 6, 2009

Vital points to remember about Virtual Objects

Hi All,

Below are the important points which need to be noticed by us prior to using Virtual Objects in QTP.

Important Points :
1. A group of Virtual Objects are stored in Virtual Object Manager under a descriptive name known as “Virtual Object Collection”.

2. Analog & Low-level recording on Virtual Objects is not supported by QTP.

3. Recognition of Virtual Objects can be disabled without deleting them from Virtual Object Manager.

4. Virtual Objects can only be used when recording & Running the tests. Any type of checkpoint on a virtual object cannot be inserted.

5. The Virtual Object Collections shown in the Virtual Object Manager are stored in our computer (where they are created) and not in the tests that include the virtual object steps. This means that if you the virtual object in a script, the object will be recognized during the run session only if it is run on the computer containing the appropriate Virtual Object Definition. To Copy your virtual object definitions to another computer, copy the contents of your \Dat\VoTemplate folder (or individual collection files within this folder) to the same location on the destination computer.

6. Virtual Objects can only be defined for objects on which you can click or Dbl click and that record a click or Dbl click operation. Otherwise, the virtual object is ignored. For example, if you define a virtual Object manager over the WinList object, the “Select” operation is recorded, and the virtual Object operation is ignored.

7. You cannot use the Object Spy to view the properties of Virtual Object.

Few Enhancements need to be incorporated in QTP

Hi ,
Many times people tend to ask what Limitations does QTP has.
Now it is very difficult for one to list out clear limitations of a tool but it is far more easier for one to point the enhancements required.
With now over 5 years of experience from QTP 8 to QTP 10, thought of highlighting all the enhancements that we could think of.

Lets hope HP would look at few of these seriously and incorporate them in upcoming version of QTP. :):):)

In case you can think of other enhancements that can be included in the below then do let us know .

Object Spy Enhancements :
1. Object spy to have an option to export all the objects in hierarchy with their properties and methods to a XLS/XML file. And also to have an option to reload this offline. This feature would help for others to analyze a object recognition remotely
2. Object spy to have the ability to run without QTP. Currently object spy can only be loaded through QTP
3. Object spy to have an option to disable the Auto spy. Currently hovering on any object displays it properties without the need to click the object. This at time gives poor performance while spying objects
4. Currently Object Spy button gets disabled when the script is run, one has to launch object repository and then launch Object Spy from there. The Object Spy should enable directly when the script is run
5. Object Spy Automation capability, so other tools can leverage the same and automate the OR creation based on custom rules
IDE Enhancement
6. Ability to open multiple scripts at one time
7. Project explorer with capability to create folder and organize library files in them
8. Improved Intellisense for objects created through DotNetFactory
9. Intellisense for VBScript classes
10. Function folding in the IDE
11. Transition from Design mode to Run mode causes too many flickers in the IDE UI. This needs to be smooth
12. Ability to view code for Test flow in Expert view. This is currently only possible through Keyword view
13. Design time non-syntax error check for issues like Duplicate variable declaration etc
14. Intellisense of current associated libraries in all Libraries. Currently if Lib1 and Lib2 are associated with a Test. The Lib1 will only show Intellisense for Lib1 and not for Lib2. The Test will show Intellisense for both Lib1 and Lib2. This creates difficulty when Lib2 functions need to be called in Lib1

Object Repository Enhancements :
15. Ability to create and load OR’s from QTP script itself
16. Ability to load Shared ORs dynamically to all the Actions. Currently RepositoriesCollection.Add methods adds the SOR to the current Action only and not other actions
17. Changes made through SetTOProperty in one Action does not get propagated to Next Action
18. Ability to enumerate all child objects present in the OR for a specified object
19. Ability to specify nickname for Objects. This would help get a complete object hierarchy through just the nick name
Object Repository Manager Enhancements
20. Ability to load and save directly to OR in XML format
21. Ability for multiple users to access the Shared OR at the same time for updating
22. Export/Import of Checkpoints from one SOR to another
23. Merging of SOR’s to an existing SOR. Currently when two SOR are merged, the merged SOR needs to be saved as a different file
24. Ability to update code when conflict resolution renames object during SOR merge. In case object A and B are merged and name A is chosen over B, all scripts using name B needs to be updated manually
Scripting Enhancements
25. More options for other scripting languages i.e. JScript, VB.NET, C#.NET etc…
26. Support for start and finish events in Action and Test. E.g. – Test_Init, Test_Terminate, Action_Init, Action_Terminate. Currently this can be achieved through use of class but it would be easier for people to use if the functionality is built-in
27. Ability to execute specified VBScript even before the test execution starts. This script would run outside QTP and would help make changes to QTP settings that cannot be done during run-time. This would help in overcoming limitations like Libraries cannot be associated at run-time
28. Ability to execute specified VBScript even after the test execution starts. This script would run outside QTP and would help perform post execution code. This would be helpful in scenarios like sending email with the report
29. Ability to create error handler functions which are automatically called when an error occurs
30. Performance improvement when using Descriptive programming when compared to Object Repository usage
31. Ability to Debug libraries loaded during run-time using Execute, ExecuteGlobal and ExecuteFile
32. Ability to register generic functions for any object type. Currently RegisterUserFunc can only be used to register the method for a single object type. So if a new Set method is created then multiple RegisterUserFunc statements need to be written. QTP should provided some way to use a pattern or something to apply the same method to multiple object types
33. Ability to Unlock a locked system from within the code34. Ability to prevent screen locking during the execution
35. Ability to debug error which occurs during terminations of script. Currently any errors that occur during the termination of the script cannot be debugged and launches.

Recovery Scenarios Enhancements:
36. Recovery scenarios (RS) to run in a separate thread. Currently recovery scenarios run in the same thread as QTP. This causes recovery scenarios to be useless in case a Modal dialog blocks QTP
37. Option to stop chaining in recovery scenarios. Currently if RS1 and RS2 both match the trigger criteria then both of the scenarios are executed. There is no way to specify that RS2 should not be executed if RS1 is executed
38. Currently there is no way to enumerate recovery scenarios present in a File
39. Recovery scenarios don’t work when they are associated at run-time
Test Reporting Enhancements:
40. Ability to create reports in different format. Excel, Word, HTML etc…
41. Reporting of errors or failure in different categories and priority. E.g. – Reporting a error with severity, priority and category (Application, Script, Validation, Checkpoint)
42. Exact location of the error in the script. This should include the line of code, error number, error statement
43. Direct ability to send report to a specified list of email addresses when the test end
44. Currently the reports can only be viewed through QTP reporter viewer and cannot be viewed on machines without this tool. Report should be made completely Web compatible so that I can be viewed in any browser in the same way it is displayed in report viewer
45. Ability to view status of current Action. Currently Reporter.RunStatus only provides the status of whole test and not for current action
46. Ability to enumerate the current status from within a Test i.e. Actions executed with details, checkpoints executed with details, recovery scenarios executed with details
Checkpoint Enhancements:
47. Ability to alter properties of all checkpoints during run-time. E.g. Expected bitmap of a bitmap checkpoint, expected values of a Table/DB checkpoint etc
48. Ability to create checkpoints at run-time
49. Ability to load checkpoints from a external file at run-time
50. Ability to enumerate all checkpoints present in current script

Keyword-Driven Testing

Hi ,
Most of the times , we might have noticed the term "Keyword Driven Testing" in QTP.

So, let's know some thing more about the Keyword Driven Testing.

This requires the development of data tables and keywords, independent of the test automation tool used to execute them and the test script code that "drives" the application-under-test and the data. Keyword-driven tests look very similar to manual test cases. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test. In this method, the entire process is data-driven, including functionality.

Once creating the test tables, a driver script or a set of scripts is written that reads in each step executes the step based on the keyword contained the Action field, performs error checking, and logs any relevant information.

Merits of keyword driven testing
The merits of the Keyword Driven Testing are as follows,
-> The Detail Test Plan can be written in Spreadsheet format containing all input and verification data.
-> If "utility" scripts can be created by someone proficient in the automated tool’s Scripting language prior to the Detail Test Plan being written, then the tester can use the Automated Test Tool immediately via the "spreadsheet-input" method, without needing to learn the Scripting language.

->The tester need only learn the "Key Words" required, and the specific format to use within the Test Plan. This allows the tester to be productive with the test tool very quickly, and allows more extensive training in the test tool to be scheduled at a more convenient time.

Demerits of keyword driven testing
-> Development of "customized" (Application-Specific) Functions and Utilities requires proficiency in the tool’s Scripting language. (Note that this is also true for any method)
-> If application requires more than a few "customized" Utilities, this will require the tester to learn a number of "Key Words" and special formats. This can be time-consuming, and may have an initial impact on Test Plan Development. Once the testers get used to this, however, the time required to produce a test case is greatly improved.

Note: Keyword-Driven Testing is generally implemented in Keyword Driven Framework.

Hybrid Test Automation Framework

Here we go about Hybrid Test Automation Framework.

Prior to knowing about the Hybrid Test Automation Framework , weshould know about the existing frameworks.
Generally we have,
  1. Data Driven Framework
  2. Test Script Modularity Framework
  3. Keyword Driven Framework
  4. Test Library Architecture Framework
  5. Hybrid Framework

Hybrid Framework is the most commonly implemented framework is a combination of of the above techniques, pulling from their strengths and trying to mitigate their weaknesses.

This Hybrid test automation framework is what most frameworks evolve into over time and multiple projects.

Hybrid Automation Frameworks generally can accommodate any of the below:

Keyword-Driven & Data Driven

Test Script Modularity & Data Driven

Keyword-Driven,Data Driven & Test Library Architecture so on so forth.

Thursday, September 17, 2009

Creating MS Word document using QTP

Hi ,
Let us create a very simple document in MS Word using the script.
Check the below script:
Dim obj_MSWord
Set obj_MSWord = CreateObject("Word.Application")obj_MSWord.Documents.Add
obj_MSWord.Selection.TypeText "This is a simple text"
obj_MSWord.ActiveDocument.SaveAs "D:\qtpkingblogspot.doc"
Set obj_MSWord=Nothing

Lock your PC automatically after the execution of QTP Scripts

Hi ,
The beauty of Automation Testing is that Scripts are run in an unattended mode.
Thus, what people usually do is, prepare the batch of scripts and leave for their homes. After the batch gets over, no matter even if it passes or even get failed, the PC is unlocked inviting others to view your secret project related data.
This remains a small issue in a simple project based company.
However it can become extremely devastating issue in case of a company having Finance or Banking related projects, having top most concern for the security of its data.
So one wonders as to what can be the way by which this situation can be tackled?

You can use the following QTP Script to lock your PC :
Set obj = CreateObject("WScript.Shell")
sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
obj.Run sCmnd, 0, False
The above QTP script will lock your PC automatically.
Moreover, I will suggest you to create this script as a separate script and call this script lastly in your batch. This will solve the purpose :)

Monday, June 29, 2009

Create TABLE in MS ACCESS Database thru script

Hi All,
Here i am providing the way of creating the table in MS Access database.
Set oConn = CreateObject( "ADODB.Connection" )
oConn.Open "QT_Flight32"
oConn.Execute "CREATE TABLE EventTable(" & _ "EventKey COUNTER ," & _ "Category TEXT(50) ," & _ "ComputerName TEXT(50) ," & _ "EventCode INTEGER ," & _ "RecordNumber INTEGER ," & _ "SourceName TEXT(50) ," & _ "TimeWritten DATETIME ," & _ "UserName TEXT(50) ," & _ "EventType TEXT(50) ," & _ "Logfile TEXT(50) ," & _ "Message MEMO)"



Monday, June 22, 2009

Run Modes in QTP

Hi All,

Run modes in view of performance/speed :

Normal (displays execution marker)—Runs your test with the execution arrow to the left of the Keyword View or Expert View, marking each step or statement as it is performed. If the test contains multiple actions, the tree in the Keyword View Item column expands to display the steps, and the Expert View displays the script, of the currently running action. you can add
Delay in each step execution. You can specify the time in milliseconds that QuickTest should wait before running each consecutive step (up to a maximum of 10000 ms.)

The Normal run mode option requires more system resources than the Fast option, described below. You must have Microsoft Script Debugger installed to enable this mode.

Fast—Runs your test without the execution arrow to the left of the Keyword View or Expert View and does not expand the item tree or display the script of each action as it runs. This option requires fewer system resources. When running a test set from Quality Center, tests are automatically run in Fast mode, even if Normal mode is selected

Run Modes in the view of Updating of Test objects/Maintenace of Test scripts :

Maintenance Run Mode: Helps to repair the test in runtime and also Pause on any failure and interactively fix the failed step.
Update Run Mode: Updates test object descriptions; checkpoint, output value properties; Active Screen images and values.

Sunday, May 24, 2009

Script for Highlighting the Objects

Hi All,

Hope most of you people might be knowing how to highlight an Object in Object Repository using "Highlight in Application" button.
Here i am providing a way of Highlighting the Objects of specific Class programmatically(thru script).

' script :
systemutil.Run ""
Dim obj Set obj=Description.Create
Set x=browser("QTP for you ...").Page("QTP for you ...").ChildObjects(obj)
For i=0 to x.count-1

'Note: Add 'Page' object into Obj.Repo. before execution
Just execute the above script & watch the output.....:)

Msgbox Vs Print Dialog

Hi All,

You might be familiar with usage of 'Msgbox' in the scripts for displaying the information,Variables,Values.
But from QTP 9.x series HP has introduced a new feature Called "Print" Statement.
The purpose of the Print Statement is similar to Msgbox , see below to have clear picture.
Msgbox VBScript function is used to display information during the run session.
Note: The run session pauses until the message box is closed.
So while runnings batch testing,Driver scripts we have to make sure that we have not used "Msgbox" in our scripts. The run session pauses until the message box is closed & we cannot expect the test results until run session is completed.
Print :
Print Utility statement is used in our scripts to display information in the QuickTest Print Log window while still continuing the run session.
Note: The run session wouldn't pauses inspite of the display of QuickTest Print Log window.
So while runnings batch testing,Driver scripts if at all we have used 'Print' statements it would not effect the test script execution(Run session) & we would get the test results.
See the below Example
' Using Print Statement:
print "ASCII value of A : "&Asc("A")
print "ASCII value of a : "&Asc("a")
print "ASCII value of B : "&asc("B")
print "ASCII value of b : "&asc("b")



Saturday, May 23, 2009

Function for Excel Cell Colors

Hi All,
Hope all of you are doing well....:)
Here i am providing an Userdefined Function for displaying the cell colors of Excel document.

' Function Defination:
Function ExcelCellColors_display(FilePath)
Dim xl
Set xl=CreateObject("Excel.Application")
xl.WorkBooks.Open FilePath
' Retrieving the rowcount used

' Clearing the existing Data in excel (If any)
For j=1 to rc
xl.cells(1,2).value="Color Index"

' Filling the colors & colorindex values
For i=2 to 56
Set xl=nothing
End Function

'Function Declaration/Calling:
Call ExcelCellColors_display( "D:\Documents and Settings\Sree\Desktop\Excel_colors.xls")


Sunday, April 26, 2009

Get Size of Folder/File

Hi All,

Here iam providing a simple way of finding the size of required folder/file.
Try the below code & implement the same wherever & whenever applicable/required.

' Get the size of folder:
dim fso
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set folder1 = fso.GetFolder( "D:\Documents and Settings\Sree\Desktop\"&foldername)
msgbox "Size of Folder "&foldername&" :- "&folder1.Size&" bytes"
Set fso=Nothing
' Output :

' Get the size of file:
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set folder1 = fso.Getfile("D:\Documents and Settings\Sree\Desktop\"&fname&".doc")
msgbox "Size of File "&fname&" :- "&folder1.Size&" bytes"
Set fso=Nothing

' Output :

Saturday, April 18, 2009

QTP 10.0 Window - Key Elements

Hi All,
Here i am giving an overview of key elements of the QuickTest Window .
The QuickTest window displays your testing documents in the document area.
You can work on one test and one or more function libraries simultaneously. (For your convenience, you can display one active document in the document area, or you can cascade or tile your open documents.)

The document area of the QuickTest window can display the following:

Enables you to create, view, and modify your test in Keyword View or Expert View.
Function Library:
Enables you to create, view, and modify functions (operations) for use with your test.
Start Page:
Welcomes you to QuickTest and provides links to Process Guidance. You can use the shortcut buttons to open new and existing documents.
Key Elements in the QuickTest Window :
In addition to the document area, the QuickTest window contains the following key elements:

QuickTest title bar:
Displays the name of the active document. If changes have been made since it was last saved, an asterisk (*) is displayed next to the document name in the title bar.

Menu bar:
Displays menus of QuickTest commands.

Standard toolbar:
Contains buttons to assist you in managing your document.

Automation toolbar:
Contains buttons to assist you in the testing process.

Debug toolbar:
Contains buttons to assist you in debugging your document. (Not displayed by default)
Edit toolbar:
Contains buttons to assist you in editing your test or function library.

Insert toolbar:
Contains buttons to assist you when working with steps and statements in your test or function library.

Tools toolbar:
Contains buttons with tools to assist you in the testing process.

View toolbar:
Contains buttons to assist you in viewing your document.

Action toolbar:
Contains buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow. (Not displayed by default)

Document tabs and scroll arrows:
Enables you to navigate open documents in the document area by selecting the tab of the document you want to activate (bring into focus). When there is not enough space in the document area to display all of the tabs simultaneously, you can use the left and right arrows to scroll between your open documents.

Keyword View:
Contains each step, and displays the object hierarchy, in a modular, icon-based table.

Expert View:
Contains each step as a VBScript line. In object-based steps, the VBScript line defines the object hierarchy.
Status bar: Displays the status of the QuickTest application and other relevant information.

You can show or hide the following panes from the View menu:
Active Screen:
Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.
Data Table:
Assists you in parameterizing your test. The Data Table contains the Global tab and a tab for each action.
Debug Viewer pane:
Assists you in debugging your document. The Debug Viewer pane contains the Watch, Variables, and Command tabs.
Information pane:
Displays a list of syntax errors found in your test and function library scripts.
Missing Resources pane:
Provides a list of the resources that are specified in your test but cannot be found, such as missing calls to actions, unmapped shared object repositories, and parameters that are connected to shared object repositories. The Missing Resources pane then enables you to locate or remove them from your test.
Process Guidance panes:
Displays two panes that provide procedures and descriptions on how to best perform specific processes, such as creating a test in QuickTest. The Process Guidance Activities pane lists the activities that you can perform, such as adding steps to a test. The Process Guidance Description pane describes the tasks that you need to perform for a selected activity. Your organization may also provide you with process guidance that is accessible from these panes.
Available Keywords Pane:
Displays all the keywords available to your test. Enables you to drag and drop objects or calls to functions into your test.
Test Flow Pane:
Displays the hierarchy of actions and action calls in the current test, and shows the order in which they are run.
Resources Pane:
Displays all the resources associated with your current test and enables you to manage these resources.
You can customize the layout of the QuickTest window by moving, resizing, displaying, or hiding most of the elements. QuickTest remembers your preferred layout settings and opens subsequent sessions with your customized layout
Given below is the view of QTP 10.0 window:

Parameterization & Types of Parameters in QTP

Hi All,
I hope while learning/working on QTP you might have heard about the term "Parameterization".

"Parameterization" : Its a process of passing multiple values(test data/Input Data) for a constant value(Hard Coded) inorder to retest certain functionality/feature.

Data Driven Testing(Retesting) can be done using the Parameterization.

There are 4 types of parameters:
1) Test/action parameters
2) Data Table parameters
3) Environment variable parameters
4) Random number parameters

Test/action parameters :
Test parameters enable you to use values passed from your test. Action parameters enable you to pass values from other actions in your test.
To use a value within a specific action, you must pass the value down through the action hierarchy of your test to the required action. You can then use that parameter value to parameterize a step in your test. For example, suppose that Action3 is a nested action of Action1 (a top-level action), and you want to parameterize a step in Action3 using a value that is passed into your test from the external application that runs (calls) the test. You can pass the value from the test level to Action1, then to Action3, and then parameterize the required step using this action input parameter value (that was passed through from the external application).
Alternatively, you can pass an output action parameter value from an action step to a later sibling action at the same hierarchical level. For example, suppose that Action2, Action3, and Action4 are sibling actions at the same hierarchical level, and that these are all nested actions of Action1. You can parameterize a call to Action4 based on an output value retrieved from Action2 or Action3. You can then use these parameters in your action step.

Data Table parameters :
Enable you to create a data-driven test (or action) that runs several times using the data you supply. In each repetition, or iteration, QuickTest uses a different value from the Data Table.
For example, suppose your application includes a feature that enables users to search for contact information from a membership database. When the user enters a member's name, the member's contact information is displayed, together with a button labelled View 's Picture, where is the name of the member. You can parameterize the name property of the button using a list of values so that during each iteration of the run session, QuickTest can identify the different picture buttons.

Environment variable parameters:
Enable you to use variable values from other sources during the run session. These may be values you supply, or values that QuickTest generates for you based on conditions and options you choose.
For example, you can have QuickTest read all the values for filling in a Web form from an external file, or you can use one of QuickTest's built-in environment variables to insert current information about the computer running the test.

Random number parameters:
Enable you to insert random numbers as values in your test. For example, to check how your application handles small and large ticket orders, you can have QuickTest generate a random number and insert it in a number of tickets edit box.

Monday, March 23, 2009

Virtual Objects in QTP

Hi ,

Given below is an overview of Virtual Objects in QTP.

virtual objects :
--> You can teach QuickTest to recognize any area of your application as an object by defining it as a virtual object. Virtual objects enable you to record and run tests or components on objects that are not normally recognized by QuickTest.
--> Using the Virtual Object Wizard, you can map a virtual object to a standard object class, specify the boundaries and the parent of the virtual object, and assign it a name. You can also group your virtual objects logically by assigning them to collections.

steps for creating the virtual object :
1. In QuickTest, choose Tools > Virtual Objects > New Virtual Object. Alternatively, from the Virtual Object Manager, click New. The Virtual Object Wizard opens. Click Next.
2. Select a standard class to which you want to map your virtual object.
3. Click Mark Object.
4. The QuickTest window and the Virtual Object Wizard are minimized. Use the crosshairs pointer to mark the area of the virtual object. You can use the arrow keys while holding down the left mouse button to make precise adjustments to the area you define with the crosshairs. Click Next.
5.Click an object in the object tree to assign it as the parent of the virtual object
6. In the Identify object using box, select how you want QuickTest to identify and map the virtual object.

If you want QuickTest to identify all occurrences of the virtual object, select parent only.
QuickTest identifies the virtual object using its direct parent only, regardless of the entire parent hierarchy.
For example, if the virtual object was defined using Browser("A").Page("B").Image("C"), QuickTest will recognize the virtual object even if the hierarchy changes to Browser("X").Page("Y").Image("C").
If you want QuickTest to identify the virtual object in one occurrence only, select entire parent hierarchy.
QuickTest identifies the virtual object only if it has the exact parent hierarchy.
For example, if the virtual object was defined using Browser("A").Page("B").Image("C"), QuickTest will not recognize it if the hierarchy changes to Browser("X").Page("B").Image("C").Click Next.
7. Specify a name and a collection for the virtual object. Choose from the list of collections or create a new one by entering a new name in the Collection name box.
8. To add the virtual object to the Virtual Object Manager and close the wizard, select No and then click Finish.
To add the virtual object to the Virtual Object Manager and define another virtual object, select Yes and then click Next. The wizard returns to the Map to a Standard Class screen, where you can define the next virtual object.

Delete Cookies through QTP

Hi All,
Here i am providing the way of Deleting the Cookies from the browser.

' Way 1:
systemutil.Run "D:\Program Files\Internet Explorer\iexplore.exe"
Dim brw
Set brw=Description.Create()
brw( "micclass" ).Value ="Browser"

Browser(brw).WinToolbar("Class Name:=WinToolbar","nativeclass:=ToolbarWindow32","Location:=0").Press "&Tools"

Browser(brw).WinMenu("menuobjtype:=3").Select "Delete Browsing History..."

Browser(brw).Dialog("Class Name:=Dialog","text:=Delete Browsing History").WinButton("Class Name:=WinButton","text:=Delete c&ookies...").Click

Browser(brw).Dialog("Class Name:=Dialog","text:=Delete Browsing History").Dialog("text:=Delete Cookies").WinButton("Class Name:=WinButton","text:=&Yes").Click

Browser(brw).Dialog("Class Name:=Dialog","text:=Delete Browsing History").WinButton("Class Name:=WinButton","text:=&Close").Click


' Way 2 :
Function ClearCookies()
SystemUtil.Run "Control.exe","inetcpl.cpl"
Set objShell = CreateObject("Wscript.Shell")
Do Until Success = True
Success = objShell.AppActivate("Internet Properties")
objShell.Sendkeys "%i"
objShell.Sendkeys "{ENTER}"
objShell.Sendkeys "%f"
objShell.Sendkeys "%d"
objShell.Sendkeys "{ENTER}"
objShell.Sendkeys "{ENTER}"
End Function

' Call the above function
Call ClearCookies()

Retrieve Extension names of the files

Hi ,
How to Retrieve Extension names of the files ?
Check it out with the below function .

Function GetAnExtension(Required_File)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetAnExtension = fso.GetExtensionName(Required_File)
End Function

msgbox GetAnExtension("D:\Documents and Settings\Sree\Desktop\VBgrids.doc")

Output will be :

Using the Windows API in QTP

Hi All,
Here i am providing an overview of usage of Windows API in QTP.

Windows API :
Using the Windows API, you can extend testing abilities and add usability and flexibility to your tests and function libraries. The Windows operating system provides a large number of functions to help you control and manage Windows operations. You can use these functions to obtain additional functionality.
The Windows API is documented in the Microsoft MSDN Web site, which can be found at:
A reference to specific API functions can be found at:
To use Windows API functions:
1. In MSDN, locate the function you want to use in your test or function library.
2. Read its documentation and understand all required parameters and return value(s).
3. Note the location of the API function. API functions are located inside Windows DLLs. The name of the DLL in which the requested function is located is usually identical to the Import Library section in the function's documentation. For example, if the documentation refers to User32.lib, the function is located in a DLL named User32.dll, typically located in your System32 library.
4. Use the QuickTest Extern object to declare an external function. For more information, refer to the QuickTest Professional Object Model Reference.
The following example declares a call to a function called GetForegroundWindow, located in user32.dll:
Extern. Declare micHwnd, "GetForegroundWindow", "user32.dll", "GetForegroundWindow"
5. Call the declared function, passing any required arguments, for example, hwnd = Extern.GetForegroundWindow().
In this example, the foreground window's handle is retrieved. You can enhance your test or function library if the foreground window is not in the object repository or cannot be determined beforehand (for example, a window with a dynamic title). You may want to use this handle as part of a programmatic description of the window, for example:
In some cases, you may have to use predefined constant values as function arguments. Since these constants are not defined in the context of your test or function, you need to find their numerical value to pass them to the called function. The numerical values of these constants are usually declared in the function's header file. A reference to header files can also be found in each function's documentation under the Header section. If you have Microsoft Visual Studio installed on your computer, you can typically find header files under X:\Program Files\Microsoft Visual Studio\VC98\Include.

For example, the GetWindow API function expects to receive a numerical value that represents the relationship between the specified window and the window whose handle is to be retrieved. In the MSDN documentation, you can find the constants: GW_CHILD, GW_ENABLEDPOPUP, GW_HWNDFIRST, GW_HWNDLAST, GW_HWNDNEXT, GW_HWNDPREV and GW_HWNDPREV. If you open the WINUSER.H file, mentioned in the GetWindow documentation, you will find the following flag values:
* GetWindow() Constants
#define GW_HWNDFIRST 0
#define GW_HWNDLAST 1
#define GW_HWNDNEXT 2
#define GW_HWNDPREV 3
#define GW_OWNER 4
#define GW_CHILD 5
#define GW_MAX 6
The following example retrieves a specific menu item's value in the Notepad application.
' Constant Values:
Const MF_BYPOSITION = 1024

'API Functions Declarations
Extern.Declare micHwnd,"GetMenu","user32.dll","GetMenu", micHwnd
Extern.Declare micInteger,"GetMenuItemCount","user32.dll","GetMenuItemCount", micHwnd
Extern.Declare micHwnd,"GetSubMenu","user32.dll","GetSubMenu", micHwnd, micInteger
Extern.Declare micInteger,"GetMenuString","user32.dll","GetMenuString", micHwnd, micInteger, micString+micByRef, micInteger, micInteger
hwin = Window("Notepad").GetROProperty ("hwnd") ' Get Window's handle
MsgBox hwin
men_hwnd = Extern.GetMenu(hwin)' Get window's main menu's handle
MsgBox men_hwnd

‘Use API Functions
item_cnt = Extern.GetMenuItemCount(men_hwnd)
MsgBox item_cnt
hSubm = Extern.GetSubMenu(men_hwnd,0)
MsgBox hSubm
rc = Extern.GetMenuString(hSubm, 0,value, 64 ,MF_BYPOSITION)
MsgBox value

Sunday, March 22, 2009

Create Log Files in QTP

Hi All ,
Here i am providing the function which creates Log files in QTP.

' Function: WriteLog
' description : Writes a message to a log file. File is created
' inside a Log folder of the current directory or on the Desktop
' Parameters :
'strCode is a code to prefix the message with.
'strMessage is the message of file.
Function WriteLog(strCode, strMessage)
Dim objFS
Dim objFile
Dim objFolder
Dim strFileName
Set objFS = CreateObject("Scripting.FileSystemObject")
If Not objFS.FolderExists(objFS.GetAbsolutePathName(".") & "\log") Then
Set objFolder = objFS.CreateFolder(objFS.GetAbsolutePathName(".") & "\log")
End If
strFileName = objFS.GetAbsolutePathName(".") & "\log\" & year(date) & month(date) & day(date) & ".log"
Set objFile = objFS.OpenTextFile(strFileName, 8, True)
On Error Resume Next
objFile.Write Date & ", " & Time & ", " & strCode & ", " & strMessage & vbcrlf
' disable the on error statement
On Error GoTo 0
Set objFS = Nothing
End Function

'Function Calling :
call WriteLog("Fail","Invalid User Credentials")

Output will be :

QTP - Testing Process

Hi All,
Here iam providing the Pictorial view of the Testing Process of the QTP.

Self Closing Message Box

Hi All,
As we all know that manual intervention is mandatory when we are using message boxes.
Until & unless we click "OK" messagebox will not closed.

Here i am providing a function through which mesage box closes automatically (without manual intervention)

' Function Defination
Function Selfclose_msgbox(msgboxtitle,boxcontent)
Dim x,y
Set x=CreateObject("WScript.Shell")
Set x=Nothing
Set y=Nothing
End Function

' Function Declaration/Calling :
Call Selfclose_msgbox("country Name","which country you are from")

Output will be :

This message box will be closed in 2 seconds automatically.

BreakPoints in QTP

Hi ,

Here i am providing the brief overview on "BreakPoints" in QTP.

Do understand the use of breakpoints & start implementing these accordingly.

Using Breakpoints :
We can use breakpoints to instruct QuickTest to pause a run session at a predetermined place in a component or function library. QuickTest pauses the run when it reaches the breakpoint, before executing the step. we can then examine the effects of the run up to the breakpoint, make any necessary changes, and continue running the component or function library from the breakpoint.
You can use breakpoints to:
* suspend a run session and inspect the state of your site or application.
* Mark a point from which to begin stepping through a component or function library using the step commands
* We can set breakpoints, and we can temporarily enable and disable them. After we finish using them, we can remove them from your component or function library.
Note: Breakpoints are applicable only to the current QuickTest session and are not saved with your component or function library.

Operations we can perform on Breakpoints:
* Setting Breakpoints
* Enabling and Disabling Breakpoints
* Removing Breakpoints

* Setting Breakpoints:
By setting a breakpoint, we can pause a run session at a predetermined place in a component or function library. A breakpoint is indicated by a filled red circle icon in the left margin adjacent to the selected step.
To set a breakpoint:
Perform one of the following:
*Click in the left margin of a step in script/function library where you want the run to stop
*Click a step and then:
Click the Insert/Remove Breakpoint button
Choose Debug > Insert/Remove Breakpoint
The breakpoint symbol is displayed in the left margin of the script or function library.
Note: Breakpoints are applicable only to the current QuickTest session and are not saved with your component or function library.

* Enabling and Disabling Breakpoints :
We can instruct QuickTest to ignore an existing breakpoint during a debug session by temporarily disabling the breakpoint. Then, when you run our component or function library, QuickTest runs the step containing the breakpoint, instead of stopping at it. When we enable the breakpoint again, QuickTest pauses there during the next run. This is particularly useful if your component or function library contains many steps, and you want to debug a specific part of it.
We can enable or disable breakpoints individually or all at once. For example, suppose we add breakpoints to various steps throughout your component or function library, but for now you want to debug only a specific part of your document. We could disable all breakpoints in your script or function library, and then enable breakpoints only for specific steps. After you finish debugging that section of your document, you could disable the enabled breakpoints, and then enable the next set of breakpoints (in the section you want to debug). Because the breakpoints are disabled and not removed, we can find and enable any breakpoint, as needed.
An enabled breakpoint is indicated by a filled red circle icon in the left margin adjacent to the selected step.
A disabled breakpoint is indicated by an empty circle icon in the left margin adjacent to the selected step.
Note: Breakpoints are applicable only to the current QuickTest session and are not saved with your component or function library.

We can:
Enable/disable a specific breakpoint
Enable/disable all breakpoints
To enable/disable a specific breakpoint:
Click in the line containing the breakpoint you want to disable/enable.
Choose Debug > Enable/Disable Breakpoint or press Ctrl+F9. The breakpoint is either disabled or enabled (depending on its previous state).
To enable/disable all breakpoints:
Choose Debug > Enable/Disable All Breakpoints or click the Enable/Disable All Breakpoints button. If at least one breakpoint is enabled, QuickTest disables all breakpoints in the component or function library. Alternatively, if all breakpoints are disabled, QuickTest enables them.

* Removing Breakpoints:
You can remove a single breakpoint or all breakpoints defined for the current component or function library.
To remove a single breakpoint:
Perform one of the following:
Click the breakpoint.
Click the line in your component or function library with the breakpoint symbol and:
Click the Insert/Remove Breakpoint button.
Choose Debug > Insert/Remove Breakpoint.
The breakpoint symbol is removed from the left margin of the QuickTest window.
To remove all breakpoints:
Click the Clear All Breakpoints button, or choose Debug > Clear All Breakpoints. All breakpoint symbols are removed from the left margin of the QuickTest window.

Working with Debug Viewer in QTP

Hi All,
Here i am providing an overview of Debug Viewer & its usage in QTP.

Using the Debug Viewer :
We use the Debug Viewer pane to view, set, or modify the current value of objects or variables in your function library, when it stops at a breakpoint, or when a step fails and you select the Debug option.

The Debug Viewer is useful for debugging operations (functions) in a business component, but is not intended for use with other types of component steps.

To open the Debug Viewer pane:
Choose View > Debug Viewer or click the Debug Viewer button.
The Debug Viewer pane opens.

The Debug Viewer tabs are used to display the values of variables and objects in the main script of the selected subroutine.
Debug Viewer consists of three tabs:
* Watch Tab
* Variables Tab
* Command Tab

Watch Tab:
You can view the current value of any variable or VBScript object in your function library by adding it to the Watch tab. As you continue stepping into the subsequent steps in your function library, QuickTest automatically updates the Watch tab with the current value for any object or variable whose value changes. You can also change the value of the variable manually when the function library pauses at a breakpoint.

To add an expression to the Watch tab:
Perform one of the following:
Click the expression and choose Debug > Add to Watch.
Click the expression and press Ctrl+T.
Right-click the expression and choose Add to Watch from the context menu.
In the Watch tab, paste or type the name of the object or variable into the Name column and press Enter to view the current value in the Value column.
Note: You can add an expression to the Watch tab from a function library (and not from a business component).

Variables Tab:
QuickTest automatically displays the current value of all variables in the current function in the Variables tab—up to the point where the function library is stopped or paused.

For example, if you are stepping through a function, as you step into each step, QuickTest adds the current value for any step variable to the Variables tab grid. As you continue stepping into the subsequent steps, QuickTest automatically updates the value displayed in the Variables tab for any variable whose value changes. You can also change the value of the variable manually, during the breakpoint pause.

Command Tab:
Use the Command tab to execute a line of script to set or modify the current value of a variable or VBScript object in your function library. When the run continues, QuickTest uses the value that you set.

Working with Reporter Object in QTP

Hi All,

Here iam providing an overview of Reporter Object in QTP.

Reporter Object is used for sending information to the test results. With the help of this object you can:
· Report the status of test results (like pass, fail, warning)
· Enable/Disable reporting of step(s) following the statement.
· Retrieve the folder path in which the current test's results are stored.
· Retrieve the run status at the current point of the run session.

There are some very important methods and properties associated with it.

"ReporterEvent" Method:
This is a very common method used with Reporter object.

Its syntax:
Reporter.ReportEvent EventStatus, ReportStepName, Details
Where EventStatus can be:

0 or micPass: If this step runs test passes which is shown in test report.

1 or micFail: If this step runs test fails which is shown in test report.

2 or micDone: Used to send message to the test report and does not affect status of test.

3 or micWarning: Again, used to send warning message to the test report and does not affect status of test.

ReportStepName -->name of step

Details --> are the user defined details for the given step.

For Example:
Reporter.ReportEvent micPass, "Creation Scenario Validation", " Successfully passed"

"Filter" property :
There can be situations where you don't want the full status displayed on the test report. This property can be used to selectively filter the status of your tests.

Its syntax:
Reporter.Filter = NewMode

Where NewMode can be: 0 or rfEnableAll: This is the default mode. All reported events are displayed in the Test Results.

1 or rfEnableErrorsAndWarnings: Only those events with a warning or fail status are displayed in the Test Results.

2 or rfEnableErrorsOnly: Only those events with a fail status are displayed in the Test Results.

3 or rfDisableAll: All events in the Test Results are disabled.

'ReportPath" Property :
This is used to get the path in which current test results are stored.

Its syntax:
Path_of_Results = Reporter.ReportPath

"RunStatus" Property:
This is used to get the current status of the run session

its syntax:
For Example:
if Reporter.RunStatus = 0 then

end if

Have a nice day.......

Export QTP Result Reports into PDF

Hi All ,

Here iam providing a way for exporting QTP results into PDF.

QTP 9.x and earlier versions provides the native support for exporting your test results to HTML. What will you do if you need to export it in a pdf format?Solution for exporting our results to PDF format:

1. Download PDF Creator ( from PrimoPDF (
2. Run the set up program, follow the instructions on the screen and install Primo PDF creator.
3. PrimoPDF is installed and can be accessible from File > Print (printer) option Menu.
4. Click OK and you will get this screen.
5. Select the radio button "EBook". Use Save As button to save the pdf in your desired location. Click OK
6. Your report in pdf format is ready.

Have a nice day...

QTP Support on MS Windows Vista

QuickTest Professional 9.2:
QuickTest Professional 9.2 supports Windows Vista 32-bit Edition.
Working with Windows Vista:
* The security settings in Microsoft Windows Vista may prevent you from performing a QuickTest Professional-related installation, such as a patch installation, or connecting to a Quality Center project (either directly or from QuickTest Professional). This can occur when the User Account Control (UAC) option in Windows Vista is set to ON, and you have not yet connected to a Quality Center project (if relevant).

To work with Quality Center, temporarily turn off the User Account Control (UAC) option, as follows:
1. Log in to Windows Vista as an administrator.
2. From the Control Panel, choose User Accounts > Change Security Settings.
3. Clear the Use User Account Control (UAC) to help protect your computer check box and click OK.
4. Connect to Quality Center as usual. After connecting to Quality Center, you can turn the User Account Control (UAC) option on again. Hereafter, you should be able to connect to Quality Center, as needed.

* Due to a problem opening DCOM permissions on Windows Vista, QuickTest does not run properly on a remote Windows Vista host from Quality Center.

Run RmtAgentFix.exe from the \bin folder.

* On Windows Vista, QuickTest Professional seat licenses may not work correctly if you are not logged on as an administrator. (Note that concurrent licenses work as usual.)
On Windows Vista, install QuickTest Professional and any QuickTest add-ins as an administrator. To do this, right-click setup.exe from the root folder of the QuickTest Professional installation CD and choose Run as administrator.Then, every time you open QuickTest, open it as an administrator. To do this, right-click the QuickTest Professional icon on your desktop and choose Run as administrator.

* On Windows Vista 32-bit, QuickTest Professional text recognition features (such as text checkpoints and output values, GetVisibleText and GetTextLocation test object methods, and TextUtil.GetText and TextUtil.GetTextLocation reserved object methods) are limited and are not always reliable.
Workaround: On Windows Vista, you can improve text recognition by applying the Classic Windows theme and by setting the mode key in the Windows Registry Editor to 3 - OCR only (described above).

* When using the Mercury Screen Recorder on Windows Vista, setting the Window's display settings to the Classic Windows theme may improve performance.
* Record and run session performance may be affected adversely when using the Mercury Screen Recorder on a computer running Windows Vista 32-bit or any 64-bit operating system. This is because some capture drivers (such as Blueberry or ASUS' Enhanced Display Driver) cannot be installed on these operating systems. Note that if you try to install the capture driver from the Screen Recorder Options dialog box while working on one of these operating systems, an error message is displayed.

QuickTest Professional 9.1:
QuickTest Professional 9.1 supports 'Windows Vista Beta 2-build 5384'.
Working with Windows Vista:
* When installing QuickTest Professional on Windows Vista Beta 2, the QuickTest icon is not installed on your desktop or in the Start menu. (A default icon is installed instead.)

Modify the icon manually.

* QuickTest Professional does not support the recording of operations on the Start menu of Windows Vista Beta 2.
* The security settings in Windows Vista Beta 2 may prevent you from connecting to a Quality Center project (either directly or from QuickTest Professional). This can occur when the User Account Control (UAC) option in Windows Vista is set to ON, and you have not yet connected to a Quality Center project.
To work with Quality Center, temporarily turn off the User Account Control (UAC) option, as follows:
1. Log in to Windows Vista as an administrator.
2. From the Control Panel, choose User Accounts -> Change Security Settings.
3. Clear the Use User Account Control (UAC) to help protect your computer check box and click OK.
4. Connect to Quality Center as usual. After connecting to Quality Center, you can turn the User Account Control (UAC) option on again. Hereafter, you should be able to connect to Quality Center, as needed.

* When working with Internet Explorer 7.0 Beta 3, QuickTest Professional may not recognize Web objects, even though the Web Add-in is installed and loaded.
In Internet Explorer 7.0 Beta 3, choose Tools -> Internet Options. In the Security tab, clear the Enable Protected Mode check box and click OK.

* Due to a problem opening DCOM permissions on Windows Vista Beta 2, QuickTest does not run properly on a remote Windows Vista Beta 2 host from Quality Center.
Run RmtAgentFix.exe from the \bin folder.

QuickTest Professional 9.0 and below:
QuickTest Professional 9.0 (and below) does not support Windows Vista.

VB Scripts Errors

Hi All,
Here i am providing the types of errors in VB script.

VB Script Errors :
1)Syntax Errors
2)Runtime Erros

1) Syntax Errors :
VBScript syntax errors are errors that result when the structure of one of your VBScript statements violates one or more of the grammatical rules of the VBScript scripting language. VBScript syntax errors occur during the program compilation stage, before the program has begun to be executed.
2) Runtime Errors:

VBScript run-time errors are errors that result when your VBScript script attempts to perform an action that the system cannot execute. VBScript run-time errors occur while your script is being executed; when variable expressions are being evaluated, and memory is being dynamic allocated.

Have a nice day.

WinRunner Vs QTP

Hi Folks,

Have a look on the differences on the both functionality testing Tools WinRunner & QTP.

Differences between win runner & Qtp :
  • WR is recommended only for windows application Testing
  • QTP supports Windows,Web,Activex,VB Applications by default & supports Peoplesoft,SAP,Siebel,oracle,.net,Mainframes environments also provided we install compatible Addins.

  • WR uses TSl as scripting language
  • QTP uses MS VBSript as a scripting language

  • WR doesnot have inbuilt Datatable
  • QTP has inbuilt DataTable .

  • WR supports only 4 types of checkpoints
  • QTP Supports 9 types of checkpoints ( additionally web checkpoints)

  • WR contains only script view
  • QTP contains Expert view/script view and also keyword view.

  • WR doesnot have activescreen feature
  • QTP have Active screen Feature

  • WR doesnt have Actions concept
  • QTP is a repository of actions

  • WR doesnt have environment variables concept
  • QTP supports environment variables

  • WR doesnt have interconnectivity feature with MQC
  • QTP supports this .

  • By WR we cannot test any performance issues of an appl.
  • By QTP we can accomplish upto certain extent using services object

  • WR cant run the QTP scripts.
  • We can Call the functions created in winrunner from qtp

  • WR doesnt support Debug viewer
  • QTP uses debug viewer

  • WR have two recording modes
  • QTP have three recording modes

  • WR cant Test multimedia Applications
  • QTP can Test multimedia Appl.

Have a nice day ...

Monday, March 16, 2009

Send Keyboard Input to Application

Hi All,

Sending Keyboard Input to an Application :

1st Way:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "calc.exe"
WshShell.AppActivate "Calculator"
WshShell.SendKeys "1{*}"
Wait (3)
WshShell.SendKeys "2"
WshShell.SendKeys "~"
WshShell.SendKeys "*3"
WshShell.SendKeys "~"

2nd way:
For i=1 to datatable.GetRowCount
window("Notepad").WinEditor("Edit").Type datatable("text",1)

3rd Way:
Use Mercury Device Replay feature
The Device Replay feature is used to perform mouse and keyboard actions against screen co-ordinates that are provided. The Device Replay functions are not automatically recorded, but must be programmed manually in the Expert View.
Create the Device Replay Object.

Call the desired Device Replay function.

When done with the Device Replay object, release it.


Set ws=createObject("Wscript.Shell")
ws.Run "Notepad.exe"
Set obj = CreateObject("Mercury.DeviceReplay")
Window("Text:=Untitled - Notepad").Activate
obj.PressKey 63

The PressKey method uses the ASCII value for the key.

63 is the ASCII value for F5.
ASCII values for other keys:

F1 - 59

F2 - 60

F3 - 61

F4 - 62

F5 - 63

F6 - 64

F7 - 65

F8 - 66

F9 - 67

F10 - 68

F11 - 87

F12 - 88

Sunday, March 15, 2009

Dictionary Objects in QTP

Hi All ,
Here iam providing an overview on "Dictionary Objects" in QTP.

Using the Dictionary Object :
Usage of Dictionary Objects is an alternative to using environment variables to share values between actions. The Dictionary object enables you to assign values to variables that are accessible from all actions (local and external) called in the test in which the Dictionary object is created.

'In order to have IntelliSense for the Dictionary object, and have it recognized by other actions, it is added to the registry .
Dim WshShell
Set WshShell =CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\GlobalDictionary\ProgID", "Scripting.Dictionary","REG_SZ"
Set WshShell = Nothing
' After updating the registry, you must close and reopen QuickTest Professional.

‘Available methods for Dictionary Objects :
1) Exists:
Syntax :
GlobalDictionary.Exists() ' Returns True or False

2) Remove:
Syntax :
GlobalDictionary.Remove() ' Remove a specific key

3) RemoveAll:
Syntax :
GlobalDictionary.RemoveAll ' Removes all keys

4) Add:
Syntax :
GlobalDictionary.Add , ' Create a new key and assigns its value

5) Item:
GlobalDictionary.Item() ' Gets/Sets a key value

Have a nice day folks..........

Friday, March 13, 2009

Function for Capturing Desktop Screenshot

Hi All,

Here i am providing the user defined function which will captures the screenshot of desktop & stores into required location.

' Function Defination :
Function ScreenShot()
dim strPNG
dim objDesktop
' set a unique file name using the date/time
strPNG = "C:\Screenshot_" &day(Date)&" - "&month(Date)&"-"&year(Date)&"##"& hour(time) &". "& minute(time) &". "& second(time) & ".png"

Set objDesktop=Desktop

' capture a png of the desktop
'captures the screenshot(.png img) into above specified location
objDesktop.CaptureBitmap strPNG,true

' captures the screenshot into current results folders
objDesktop.CaptureBitmap Environment("TestName")&day(Date)&" - "&month(Date)&"-"&year(Date)&".bmp",true

' destroy the object
Set objDesktop = Nothing
End Function

' Function Declaration/Calling
Call ScreenShot()

OutPut :
Screenshot of type .png will be saved in the above Loc given in Variable strPNG.
Screenshot of type .bmp will be saved into current results folders of the script.

Have a nice day.......

Thursday, March 12, 2009

QTP 9.5 & 10.0 New Features

Hi Folks,

Here iam providing the new features implemented in following QTP 9.5,10.0 versions.

QTP 9.5 New Features:

1) Process Guidance Panes

2) Missing Resources Pane

3) Test Flow Pane

4) Understanding the Resources Pane

5) Running Tests with the Maintenance Run Wizard

6) Available Keywords Pane

QTP 10.0 New Features :

1)Centrally Manage, Share Testing Assets, Dependencies & Versions in QC 10.00

2) Improve Portability by Saving Copies of Tests Together with Their Resource Files

3) Develop Your Own Bitmap Checkpoint Comparison Algorithm

4) Centrally Manage Your Work Items and ToDo Tasks in the To Do Pane

5) Improve Test Results Analysis with New Reporting Functionality

6) Test Standard and Custom Delphi Objects Using the Delphi Add-in and Delphi Add-in Extensibility

Have a nice day Folks.......

Wednesday, March 11, 2009

How to Capture ToolTips

Hi All,

Here I am providing fews ways of capturing the Tooltips of objects such as Links,Images,Web Elements So on So forth...

For Example, consider the above page. Here we will capture the Tooltip of the Webelement "Google India" shown in below fig.

' ToolTips for Web Elements:
msgbox browser("Google").Page("Google").WebElement("India").Object.title

OutPut :
In the similar way, check out the below ways of capturing ToolTips for other Object Classes too.
' ToolTips for images :
msgbox Browser("Yahoo! India").Page("Yahoo! India").Image("Click here").GetROProperty("alt")

' ToolTips for Links :
x=Browser("Yahoo! India").Page("Yahoo! India").Link("All Yahoo! Services").GetROProperty("OuterHtml")
msgbox ToolTip

Thursday, February 26, 2009

Close All Active Browsers

Hi All,
In this post, I am providing the couple of ways for closing all the active browsers .
Say there are '5' browsers which are opened.

Soultion 1 :
While Browser("CreationTime:=0").Exist

Solution 2:
systemutil.CloseProcessByName "iexplore.exe"

Output :
All 5 browsers will be closed......

Have a nice day folks.............

Get number of Files in a Folder

Hi All,
Use the following way for finding the number of files in a folder.


Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("give entire folder path here")
Set vFiles =colFolderName.Files
For each i in vFiles
msgbox "File "&Sno&" : "&FileName

msgbox "Number of files in Current Folder : "&vFiles.count

Output :

Wednesday, February 25, 2009

Find the Links Count in a Web Page

Hi All,
Here i am posting a User defined function for finding number of objects of required object Type/Class in a Google Web Page (i.e Link,Image,Web button,Web Edit...So on So forth)

' Function Defination :
Function objects_count_in_Page(Req_obj)
Dim obj
Set obj=Description.Create
Set x=Browser("Google").Page("Google").ChildObjects(obj)
Req_obj_count= x.count()
msgbox Req_obj&"s"&" in WebPage : "&Req_obj_count
End Function
Function Declarations/Function Calls of above Function:
Call objects_count_in_Page("Link")
Call objects_count_in_Page("WebButton") :
Call objects_count_in_Page("WebEdit")
Output will be :

Monday, February 23, 2009

Script for Mutlipication Tables

Hi All,
Here i am providing the way creating Multiplication Table in Notepad using QTP.
SystemUtil.Run "notepad"
Window("text:=Untitled - Notepad").Activate
For I=1 to 3
For J = 1 to 10
x = I * J
Window("text:=Untitled - Notepad").Type I &"*"& J &"=" &x
Window("text:=Untitled - Notepad").Type micReturn

Output :

Sunday, February 22, 2009

Get Column Count,Col names of DataTable

HI All,
Here i am posting the ways of retreiving the column count & column names used in datasheets of datatable.
Implement the given ways accordingly........Have a Nice day.

To Retrieve the Column count Data Table :
Syntax :
Col_count= Datatable.GetSheet("SheetName").GetParameterCount
Col_count= Datatable.GetSheet("Action1").GetParameterCount
msgbox "No. of columns used in "&Environment("ActionName")&" are : " &Col_count
To Retrieve the Column Names of Data Table :
Syntax :
Datatable.GetSheet("SheetName").GetParameter(Column Number).Name
Example1 :
msgbox " Column name is : "&Col_Name

Create List Box in VB script

Hi All,
Function Create_List_Dialog(Title, message, List)
On Error Resume Next
msg = message
for i = lbound(List) to ubound (List)
newmess = msg & vbCrLf & cstr(i + 1) & " - " & List(i)
msg = newmess
flag = 0
do while flag = 0
Ret = InputBox(msg,Title,"1")
Ret = CInt(Ret)
Create_List_Dialog = List(Ret-1)
flag = 1
If Create_List_Dialog = "" Then
flag = 1
End if
End Function

'USAGE of the above code:
domains = Array("Yahoo Mail","G Mail","Rediff Mail","Hot Mail","Sify Mail","EXITFROMTEST")
OUTPUT = Create_List_Dialog("MAIL LOGIN", "SELECT APPLICATION", domains)
msgbox OUTPUT
'Find the Output of the above code: