Wednesday, December 29, 2010

Automation Object Model - Sample QTP Script

'AOM
'Code for Automating the QTP Operation by using Automation Object Model

Option Explicit
Dim qtapp,qtrep,qtfun,qttest
set qtapp=CreateObject("QuickTest.Application")
qtapp.Launch
qtapp.Visible=true
qtapp.ActivateView "ExpertView"
qtapp.ShowpaneScreen "Datatable",True
qtapp.ShowpaneScreen "ActiveScreen",True
qtapp.ShowpaneScreen "DebugViewer",True
qtapp.Open "C:\Documents and Settings\Administrator\Desktop\Recovery"
set qtrep=qtapp.Test.Actions("Action1").ObjectRepositories
qtrep.Add "C:\Documents and Settings\Administrator\Desktop\Rep123.tsr"
set qtfun=qtapp.Test.Settings.Resources.Libraries
qtfun.Add "C:\Documents and Settings\Administrator\Desktop\funlib.vbs"
set qttest=qtapp.Test
qttest.Run
qtapp.windowstate="maximized"
qtapp.quit
set qtapp=Nothing
set qtrep=nothing
set qtfun=nothing
set qttest=nothing
'**********************************************************

QTP- Sample Code for On Error Resume Next

'Code for On Error Resume Next
Option Explicit
Dim str,pos
On Error Resume Next
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "Ram" @@ hightlight id_;_329434_;_script infofile_;_ZIP::ssf1.xml_;_
wait 1
Dialog("Login").WinEdit("Agent Name:").Type  micTab  @@ hightlight id_;_329434_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").SetSecure "70c2099ae893a36408d79e83975" @@ hightlight id_;_263888_;_script infofile_;_ZIP::ssf3.xml_;_
wait 1
Dialog("Login").WinEdit("Password:").Type  micTab  @@ hightlight id_;_263888_;_script infofile_;_ZIP::ssf4.xml_;_
Dialog("Login").WinButton("OK").Type  micReturn  @@ hightlight id_;_263902_;_script infofile_;_ZIP::ssf5.xml_;_
window("text:=Flight Reservation").Close
Msgbox Err.Number&"       :     "&Err.Description
If (err.Number<>0) Then
 str=dialog("Login").Dialog("Flight Reservations").GetVisibleText( )
 pos=Instr(1,str,"Agent name",VBTextCompare)
   If (pos<>0) Then
     Call Edit_Agent("Rama")
     Else
     Call Edit_Password("mercury")
   End If
End If
Public Function Edit_Agent(ag)
   Dialog("Login").Dialog("Flight Reservations").Close
   dialog("Login").WinEdit("Agent Name:").Set ag
   dialog("Login").WinButton("OK").Click
   window("text:=Flight Reservation").Close
   Err.Clear
   Err.Close
End Function
Public Function Edit_Password(pwd)
   Dialog("Login").Dialog("Flight Reservations").Close
   dialog("Login").WinEdit("Password:").Set pwd
   dialog("Login").WinButton("OK").Click
   window("text:=Flight Reservation").Close
   Err.Clear
   Err.Close
End Function
'****************************************************************

QTP- Passing multiple values between two actions by suing Action Parameters

Option Explicit
Dim a,b,sum1,diff1,prod1
a=10
b=20
RunAction "Action2", oneIteration,a,b,sum1,diff1,prod1
Msgbox "Sum:   "&sum1
Msgbox "Diff:   "&diff1
Msgbox "Prod:   "&prod1
--------------------------------------------------------------------
'Code for creating Input,output parameters
Option Explicit
Dim n1,n2,sum,diff,prod,s,d,p
n1=Parameter("Num1")
n2=Parameter("Num2")
sum=n1+n2
diff=n2-n1
prod=n1*n2
parameter("s")=sum
parameter("d")=diff
parameter("p")=prod
------------------------------------------------------------------
Edit-->Action-->ActionProperties-->Input,Output Parameters
'*********************************************************************
'Code for function procedures
Option Explicit
Dim a,b,sum,prod,val
a=10
b=20
Public Function Add1(ByRef a,ByRef b)
a=a+10
Msgbox "a value inside function:  "&a
b=b+10
Msgbox "b value inside function:  "&b
sum=a+b
Add1=sum
End Function
val=Add1(a,b)
'Call Add1(a,b)
'Add1 a,b
Msgbox "Sum:   "&val
Msgbox "a Value Out side Function:   "&a
Msgbox "b Value Out side Function:   "&b
'*********************************************************************
'Code for Built-In Environment Variables for reading system info
Msgbox Environment.Value("LocalHostName")
Msgbox Environment.Value("OS")
Msgbox Environment.Value("OSVersion")
Msgbox Environment.Value("ProductName")
Msgbox Environment.Value("ProductVer")
Msgbox Environment.Value("ProductDir")
Msgbox Environment.Value("TestDir")
Msgbox Environment.Value("ActionIteration")
Msgbox Environment.Value("TestIteration")
Msgbox Environment.Value("ResultDir")
'********************************************************************
'Code for reading external environment variables
Option Explicit
Dim path1
path1=Environment.ExternalFileName
Msgbox IsEmpty(path1)
If (path1="") Then
 Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\FastTrack\envfile.xml"
 Msgbox "UserID:     "&Environment.Value("UserID")
 Msgbox "Password:     "&Environment.Value("Password")
 Msgbox "Job:     "&Environment("Job")
 Msgbox "Age:     "&Environment("Age")
 Msgbox "Location:     "&Environment("Location")
 Else
 Msgbox "File Already in use:   "&path1
End If

Tuesday, December 28, 2010

What is new in QTP11?

Here is the complete list of new features that are available in QTP 11

XPath and CSS based object identification

Identify objects not only using normal object identification but with XPath and CSS identifier properties. A much awaited and a killer feature

Good Looking and Enhanced Results Viewer

The new improved results viewer provides an executive summary page with summary data, pie charts and statistics for both the current and previous runs and a quick link to the previous run results.


Easy Regular Expressions

You can now create reg ex with the help of syntax hints. Regular Expression Evaluator is available to test regular expressions that you have created. Good One.

Now identify objects not only in relation to each other but in relation to neighboring objects.

With this feature, QTP 11 has moved beyond the unreliability of ordinal identifiers. Objects identified with ordinal identifiers are good only as long as they maintain their relative positions with respect to each other in the new build of application. In case if this position changes or gets interchanged, ordinal identifiers may go for a toss.
HP has now introduced Visual Relation Identifier.
A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. You define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box.

Load Function Libraries at Run Time

With the help of LoadFunctionLibrary statement. You can now load a function library when a step runs instead of at the beginning of a run session.

Test Your GUI and UI-Less Application Functionality in One Test

Since QTP is integrated with Service Test, you can now test your GUI and non-GUI based apps in a single run.

Record Support

For FireFox is now available.

Much Awaited Log Tracking is available now

QTP 11 is capable of receiving Java or .NET log framework messages from your application which can then be embedded in the run results.

Embed/Run Javascript in web pages

You can use the new EmbedScript/EmbedScriptFromFile and RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages. You can use these scripts to perform operations on, or retrieve data from, the browser pages in your application.

Manage Test Data

Improved test data management when integrated with Quality Center

Web 2.0 Toolkit Applications Support

QTP 11 now supports Web 2.0 Toolkit Applications out-of-the-box similar to any other add-ins.

Automatically Parameterize Steps

You can instruct QTP 11 to automatically parameterize test steps at the end of record session.

Silverlight Add-in

To test objects in Silverlight 2 and Silverlight 3 applications. [After installation, Silverlight Add-in is displayed in the Add-in Manager as a child add-in under the WPF Add-in]

Extend WPF and Silverlight Support

You can use WPF and Silverlight Add-in Extensibility SDK to develop support for testing third-party and custom WPF and Silverlight controls that are not supported out-of-the-box

Use Extensibility Accelerator for Web Add-in Extensibility Development

Avoid Downtime Due to License Server Failures

Useful for concurrent license users. With redundant license servers you can create failover, so that if your main license server fails, your remaining servers maintain availability of your licenses without causing any downtime or loss of licenses for users.

QTP support for Silverlight, AJAX, GWT, Dojo, YUI now available

Reading this article from Roi Carmel, HP, prompted me to write a post. There has been no out-of-the-box support for most of the Web2.0 technologies by any of the tools providers out there. SilverlightLooks like HP has decided to go full force into it and capture all the more commercial functional testing tools market that was already dominated by them.  **HP is now planning to release a Web2.0 pack. The highlights of which will be:
  1. Making Web-Extensibility easier to use : Good to know HP acknowledge this fact. I have not seen much happening around this area, though it has been good 2+ yrs (the release of v9.5) since they made extensibility available. It will be a framework by the name Extensibility Accelerator (EA). AJAX
  2. Tighter support for Web2.0 apps : Till now, QTP had a Flex addin (by Adobe), now QTP is going to support Silverlight and AJAX apps.
  3. Better Object recognition and record/replay capabilities for Web 2.0 apps
Read the full article here
** Update: HP has already released the patch on top of QTP 10.0  This patch provides support for Silverlight 2-3 (under .NET addin),  and various toolkits – like AJAX, Google Web Toolkit (GWT), Dojo Toolkit, and Yahoo User Interface- under Web Extensibility. Once you have the Extensibility Accelerator installed, it can be seen under Tools menu option on QTP’s IDE.
The patch is released in two flavors:
  1. Web 2.0 Feature Pack with PreRequisites – In case you do not have MS Studio 2008 SP1 and .NET framework
  2. Web 2.0 Feature Pack without PreRequisites – In case you already have the above two softwares installed.
Have you downloaded the FREE Optimizing QTP eBook yet? Get It Now!
I'm sure you have already subscribed to our feed but just in case not. I recommend you to subscribe via RSS feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

AUTOMATION FRAMEWORKS

http://safsdev.sourceforge.net/FRAMESDataDrivenTestAutomationFrameworks.htm

Friday, December 24, 2010

Import CSV into QTP Datatable

'************************************************************
Function ImportCsvFiletoDatatable(CsvFilePath,SheetName,HeaderDelimiter)
Dim filePath
Dim fso
Dim f
Dim fData
Dim arrData
Dim CsvValue
Dim CsvSheet
Dim CsvFirstLine
Dim CsvColumns
Dim ColumnIndex
Dim rIndex
Dim cIndex
 
filePath=CsvFilePath    'Specify file Path
 
'Open CSV File using File System Object
Set fso=createobject("scripting.filesystemobject")
Set f  = fso.OpenTextFile(filePath)
 
CsvFirstLine=f.readline    'Treating like first line is the column names
 
CsvColumns=split(CsvFirstLine,HeaderDelimiter)    'Split the line using HeaderDelimiter
 
Set CsvSheet=DataTable.GetSheet(SheetName)    'Get the Specified sheet
 
'Add the splitted values as Datatable Columns
For ColumnIndex=lbound(CsvColumns)  to ubound(CsvColumns)
CsvSheet.addparameter CsvColumns(ColumnIndex),""
Next
 
 
While not f.AtEndOfStream
 
rIndex=f.Line-1    'Specify Row index
fData=f.ReadLine    ' Read CSV File Line
arrData=split(fData,",")    'Split the line
cIndex=1    'Specify Column Index
CsvSheet.SetCurrentRow(rIndex)    'Set Row in the Datatable
 
' Add values in Datatable
For Each CsvValue In arrData
CsvSheet.getparameter(cIndex).value=CsvValue
cIndex=cIndex+1
Next
 
Wend
 
f.Close
Set fso=Nothing
 
End Function
'************************************************************
 
'Calling this Function
ImportCsvFiletoDatatable "C:\Sample.csv","Action1","," 

QTP Preparation Questions

Try to find solutions for these Question. I will add solutions for these questions later.
1 Write a program to find the x and y coordinates of a button
2 Write a program to Read items in a list box
3 Write a program to Read items on a desktop
4 Write a program to Capture Desktop Screen shot
5 Write a program to Read tab names from a tabbed window
6 Write a program to Check whether scrollbars exists inside a editor
7 Write a program to check whether edit box is enabled or writable
8 Write a program to Check whether dialog is middle of the window
9 Write a program to Check whether country contains all the states
10 Write a program to Check whether edit box is focused
11 Write a program to Check default selection in a list box
12 Write a program to Capture webbutton image
13 Write a program to List all links in the web page
14 Write a program to Check whether given link exists or not
15 Write a program to Find image width and Height
16 Write a program to Print URL displayed in the address bar
17 Write a program to Check whether webpage downloaded completely
18 Write a program to Refresh a web page
19 Write a program to Verify page title is displayed correctly
20 Write a program to Verify whether page contains frames
21 Write a program to Find page load time
22 Write a program to Check given text is displayed on the web page
23 Write a program to Find whether image contains tool tip
24 Write a program to Invoke the Browser with specified URL
25 Write a program to Import an excel file to a Data table
26 Write a program to Read data from first parameter of Global sheet
27 Write a program to Read data from all sheets and all parameters of the excel file
28 Write a program to place data in a specific sheet in the excel file
29 Write a program to Import data to data table from a database
30 Write a program to Read and display data from CSV file
31 Write a program to Find number of rows and columns in a web table
32 Write a program to Display entire data in the web table
33 Write a program to Display all images in the webpage
34 Write a program to Check whether table contains headers
35 Write a program to Find the background colour of a webobject
36 Write a program to Print results in a HTML format
37 Write a program to Select different radio buttons for different script iterations
38 Write a program to Read all the items from a services window
39 Write a program to Find screen resolution
40 Write function to compare two bitmaps
41 Write a program to Add and Remove Repositories to the action
42 Write a program to Load Library files
43 Write a program to Enable and Disable Recovery scenarios programmatically
44 Write a program to Report Results status to Results file
45 Write a program to Find the active window name
46 Write a program to List out the windows that are open
47 Write a program to Call reusable actions from different script
48 Write your own standard checkpoint
49 Write your own synchronization function
50 Write a program to Read menu names
51 Write a program to Read menu items
52 Write a program to Check whether a check button is selected or not
53 Write a program to Check whether we can select multiple items in the listbox
54 Write a program to Check whether edit box allows exactly 15 characters
55 Write a program to Check whether items in the page are aligned properly
56 Write a program to Check whether data in the webtable is left aligned
57 Write a program to Find which add-ins are loaded.
58 Write a program to Find available add-ins in the tool
59 Write a program to Change window title
60 Write a program to Find whether specified window is there on the desktop
61 Write a program to Check whether a window is in minimized or maximized
62 Write a program to Check window is resizable
63 Write a program to Read all elements in the XML file
64 Write a program to Read attributes of a particular element in the XML file
65 Write a program to Modify attribute value
66 Write a program to Display complete contents of an XML file
67 Write a program to Find font type.
68 Write a program to Find Font size
69 Write a program to Check whether text is bold and underlined
70 Write a program to Find the memory utilized by a process
71 Write a program to Verify flash image
72 Write a program to Check pointed link is having different back ground colour?
73 Write a program to Retrieve Action Parameters
74 Write a program to Disable active screen programmatically
75 Write a program to Modify Mandatory and Assistive properties programmatically
76 Write a program to Configure Run options programmatically
77 Write a program to Define test results location through program
78 Write a program to Disable Run settings
79 Write a program to Read and Update data from user defined environmental variable
80 Write a program to Configure maximum timeout value for web page to load
81 Write a program to read and delete cookies
82 Write a program to Verify whether status indicator is moving as the movie is playing
83 Write a program to Clear the cache in the webpage
84 Write a program to Check whether webpage is loaded from server or from cache
85 Write a program to Configure web options programmatically
86 Write a program to Check whether new items can be added to a listbox
87 Write a program to Check whether link s pointing to correct URL
88 Write a program to invoke the application
89 Write a program to Read parameters in the data table
90 Write a program to List out the windows that are minimized
91 Write a program to add environmental variables during run time
92 Write a program to check whether tab order is left to right and top to bottom
93 Write a program to find the maximum text length that can be entered in a edit box
94 Write a program to verify min and max length constraints of text in an edit box
95 Write a program to find the kind of data edit box accepts
96 Write a program to add objects to object repository file
97 Write a program to export object repository file to XML
98 Write a program to check whether a column in the database table is a primary key
99 Write a program to display constraints of a column in the database table
100 Write a program to print all button object names in a page

Recovery Scenarios using VB Scripting

Working with Recovery Scenarios using Scripting

Precondition:-
To understand this topic you need to have knowledge on creating and using recovery scenarios.
In this document I am discussing about how to add, remove recovery scenario files (.QRS) to a test and after adding how to activate, deactivate and renumbering the order to execute recovery scenarios.
For example I have a recovery scenario file with the name of “sample .qrs”. Assume that in this recovery file I have two recoveries with the names loginPop, RunErr. (All of you know that one file can have multiple recoveries). Now if i want to use that file in my test then I have to use following script.

'*******************************************************************
' Create the Application object
Set qtApp = CreateObject("QuickTest.Application")
' Return the Recovery object for the current test
Set qtTestRecovery = qtApp.Test.Settings.Recovery
' Add the " loginPop " scenario as the first scenario
qtTestRecovery.Add "E:\TEST\Recoveryfiles\sample.qrs", " loginPop ", 1
' Add the " RunErr " scenario as the second scenario
qtTestRecovery.Add "E:\TEST\Recoveryfiles\sample.qrs", " RunErr ", 2
' Iterate the scenarios
For intIndex = 1 To qtTestRecovery.Count
' Enable each Recovery Scenario (Note: the 'Item' property is default and can be omitted)
qtTestRecovery.Item(intIndex).Enabled = True
Next
' Enable the recovery mechanism (with default, on errors, setting)
qtTestRecovery.Enabled = true
'Ensure that the recovery mechanism is set to be activated only after errors
qtTestRecovery.SetActivationMode "OnError"
Set qtApp = Nothing ' Release the Application object
Set qtTestRecovery = Nothing ' Release the Recovery object

'*******************************************************************

With the above code automatically the recovery scenarios will be added to the specified test. After adding the scenarios if you want to control the scenario like changing the scenario status, to get the scenario name, to activate or deactivate we have to use recovery object (one of the Utility object).

Recovery Object
It is an utility object to control the recovery scenario mechanism programmatically during the run session.
It’s having some properties and methods to control the scenarios.


Associated Methods

1. Activate Method:

Explicitly activates the recovery scenario mechanism at a specific point in the run.
Note: The Activate method only works if the recovery mechanism is enabled, and only activates those recovery scenarios that are currently enabled.
If the recovery mechanism is currently disabled, the Activate method does not activate any recovery scenarios. You can use the Recovery object's Enabled property to change the status of the recovery mechanism.
Ex:- Recovery.Activate

2. GetScenarioName Method:

Retrieves the name and source file of a recovery scenario, according to the specified position in the list of recovery scenarios associated with the test.
Ex:- Recovery.GetScenarioName Position, out_ScenarioFile, out_ScenarioName
Msgbox(out_ScenarioFile)
Msgbox(out_ScenarioName)

3. GetScenarioPosition Method

Returns the index position of a recovery scenario in the list of recovery scenarios associated with the test, according to the specified name and source file.
Ex:- Recovery.GetScenarioPosition (ScenarioFile, ScenarioName)
4. GetScenarioStatus Method
Returns the status of a recovery scenario (True = enabled or False = disabled), according to the specified index position in the list of recovery scenarios associated with the test.
Ex:- Recovery.GetScenarioStatus Position

SetScenarioStatus Method

Enables or disables the specified recovery scenario, according to its index position in the list of recovery scenarios associated with the test.
Ex:- Recovery.SetScenarioStatus Position, Status

Associated Properties
Count Property

Returns the number of recovery scenarios associated with the current test.
Ex:- msgbox Recovery.Count

Enabled Property

Recovery default property. Retrieves or sets the status of the recovery scenario mechanism for the current test.
Ex:- Recovery.Enabled =Status

'********************************************************************
Sample Script
For Iter = 1 to Recovery.Count

Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
Status = Recovery.GetScenarioStatus( Position )
Scenario=scenario& ScenarioFile&”:=”& ScenarioName&”,”&position&”,Status
Next
Msgbox Scenario
'********************************************************************
This code will show total scenarios in the QRS file, position and status of those scenarios.

QTP Useful tips

Sharing some of the useful tips on QTP I used while working and found from sqaforums.I urge the readers to share their experiences/tips they have used while working on QTP. You can use the comments section to do the same.

1) How to add a constant number in a datatable?
This is more to do with MS excel then QTP!! but useful to know because at times it becomes frustrating to the novices.
Just append ' to the number
Ex: if you wish to enter 1234567 in datatable then write it as '1234567

2) How can i check if a parameter exists in DataTable or not?
The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

3) How can i check if a checkpoint passes or not?
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else MsgBox "Check Point failed"
end if

4) My test fails due to checkpoint failing, Can i validate a checkpoint without my test failing due to checpoint failure?
Reporter.Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfEnableAll 'Enable all the reporting stuff
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if

5) What is the difference between an Action and a function?
Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.

6) Where to use function or action?
Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of using function/action depends on what any one would be comfortable using in a given situation.

7) When to use a Recovery Scenario and when to us on error resume next?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error is caused by printer device driver. "On error resume next" should be used when you know if an error is expected and dont want to raise it, you may want to have different actions depending upon the error that occurred. Use err.number & err.description to get more details about the error.

8) How to use environment variable?
A simple defintion could be... it is a variable which can be used across the reusable actions and is not limited to one reusable action.
There are two types of environment variables:
1. User-defined
2. Built-in
We can retrieve the value of any environment variable. But we can set the value of only user-defined environment variables.

To set the value of a user-defined environment variable:
Environment (VariableName) = NewValue

To retrieve the value of a loaded environment variable:
CurrValue = Environment (VariableName)

Example
The following example creates a new internal user-defined variable named MyVariable with a value of 10, and then retrieves the variable value and stores it in the MyValue variable.

Environment.Value("MyVariable")=10
MyValue=Environment.Value("MyVariable")

9) What are the files and subfolders of a QuickTest Professional test?

The files and folders hold binary and text data that are required for the test to run successfully.
The following table provides a description, the type, and comments regarding the files that make up a QuickTest Professional test.


File Name

Description

Type

Comments Regarding File

Test.tsp

Test settings

Binary

Do not edit

Default.xls

Data table parameters

Excel similar

Can be edited using Excel

Parameters.mtr

Parameterization information

Binary

Do not edit

Action

Action folder (See other table)



Default.cfg

Load test configuration file

Text

Do not edit

Default.prm

Load test configuration file

Text

Do not edit

Default.usp

Load test configuration file

Text

Do not edit

.usr

Load test configuration file

Text

Do not edit

Thick_usr.dat

Load test configuration file

Text

Do not edit

Thin_usr.dat

Load test configuration file

Text

Do not edit

Files within Action folder:


File Name

Description

Type

Comments Regarding File

Script.mts

Action script

Text

Edit text preceding the @@ sign only

Resource.mtr

Object Repository

Binary

Do not edit

Snapshots

Active screen files

Folder

Do not edit


There are few more files extensions like
.MTB Batch File
.LCK Locked


10) How to rename a checkpoint (QTP 9.0)?
Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("Edit")
In the above example, the user would like to change the name of the CheckPoint object from "Edit" to something more meaningful.
Note:
This functionality is new to QuickTest Professional 9.0.This is not available for QTP 8.2 and below.
1. Right-click on the Checkpoint step in the Keyword View or on the Checkpoint object in Expert View.
2. Select "Checkpoint Properties" from the pop-up menu.
3. In the Name field, enter the new checkpoint name.
4. Click . The name of the checkpoint object will be updated within the script.
Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("NewCheckPointName")
Note:
You must use the QuickTest Professional user interface to change the name of the checkpoint. If you manually change the name of the checkpoint in the script, QuickTest Professional will generate an error during replay. The error message will be similar to the following:


"The "" CheckPoint object was not found in the Object Repository. Check the Object Repository to confirm that the object exists or to find the correct name for the object."
The CheckPoint object is not a visible object within the object repository, so if you manually modify the name, you may need to recreate the checkpoint to resolve the error.


11) Does QuickTest Professional support Internet Explorer 7.0?
QuickTest Professional 9.1
QuickTest Professional 9.1 supports Microsoft Internet Explorer 7.0 Beta 3. Internet Explorer version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.
QuickTest Professional 9.0
QuickTest Professional 9.0 supports Internet Explorer 7.0 Beta 2.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not include support for Internet Explorer 7.0.

Does QuickTest Professional support Firefox?
QuickTest Professional 9.1 and 9.2
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla Firefox 2.0 Alpha 3 (Alpha-level support for Bon Echo 2.0a3).
Notes:

QuickTest Professional 9.1 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 9.0
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:

QuickTest Professional 9.0 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not have support for Firefox.


12) ProblemAfter Quick Test Professional is started, Windows Media will not start. It returns the error message "wmplayer.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created."
If you start Window's Media Player first, it will continue to work normally after starting QuickTest Professional.
Solution:
Include the Windows Media Player's executable in the NoBBTApps section of the mic.ini file
1. Close QuickTest Professional.
2. Go to \bin\mic.ini.
3. Include wmplayer.exe in the NoBBTApps section of mic.ini file.
Example:
[NoBBTApps]
wmplayer.exe=rek
4. Save the mic.ini file and restart QuickTest Professional.
13) What is the lservrc file in QTP?
The lservrc file contains the license codes that have been installed
The lservrc file contains the license codes that have been installed. Whenever a new license is created, the license code is automatically added to this file. The lservrc file is a text file, with no extension.
File Location:
1) For a Concurrent (Floating) license installation:

C:\Program Files\Common Files\SafeNet\ SafeNet Sentinel\ LM Server\WinN

2) For a Seat (Stand-alone) license installation:


  • QTP 9.2 and below versions: C:\Program Files\Common Files\Mercury Interactive\License Manager\lservrc
  • QTP 9.5 and above versions: C:\Documents and Settings\All Users\Application Data\HP\Functional testing\License

Virtual Objects-Descriptive Programming

When the application is having objects that are unable to identify by QTP then we will be using the concept virtual objects. We can create virtual objects using Virtual Object Manager. That created virtual objects will be stored as a VOT file in <QuickTest installation folder>\ dat \ VoTemplate. If we want to use those virtual objects in another machine or If we want to use the scripts which are using virtual objects in different machines, then We must copy the .VOT files to the machines where you want to run. Here it will become a maintenance problem. If we forgot / neglect to do that then the scripts will not work.
Descriptive Programming for Virtual Objects is the best solution to overcome this problem. In this you need not create any objects using virtual object manager. The Virtual Objects uses the properties x, y, width and height. All you need to do is you have to mention these properties & property values in script.
For example, in the below script I have virtually created a button under a page. If i execute this automatically that particular area will be highlighted. For this I haven’t created any virtual object using Virtual Object Manager.
Browser("name:=Google").Page("title:=Google").VirtualButton("x:=698","y:=128","height:=18","width:=41","name:=hi").highlight
So now I can run this script on any machine without considering VOT files.
You can even store the object information in description object and use that description object in script.
Set oVirtualDescription=Description.Create
oVirtualDescription("x").value=698
oVirtualDescription("y").value=128
oVirtualDescription("height").value=18
oVirtualDescription("width").value=41
Browser("name:=Google").Page("title:=Google").VirtualButton(oVirtualDescription).highlight

There is no facility to create VirtualEdit. We can do descriptive programming for the classes which can be created using Virtual Object Manager. The thumb rule for Virtual Objects Descriptive Programming is we have to use the properties that QuickTest learns for the virtual objects in to object repository. 

For Virtual Lists you need to use one more property "rows:=number" and use "rows:=number", "columns:=number" for virtual table. 

sample script for the beginners of Descriptive Programming.
'This is a sample script on Flight Reservation Application using Descriptive Programming
'Script Flow :- Open Flight Reservation Application --> Login --> Insert Order --> Open Order --> Delete Order
'Object Descriptions created in the script by using CreateObjectDescription Function.
'If object is using only one property then i have created a constant for it.

'*******************************************************************************
'Input Variables
'*******************************************************************************

Dim ApplicationPath
ApplicationPath=Environment("ProductDir")&"\samples\flight\app\flight4a.exe"

'*******************************************************************************
'Object Description Constants
'*******************************************************************************
'Login

Public Const Login_Dialog="text:=Login"

Set Login_Edit_AgentName=CreateObjectDescription("nativeclass:=Edit,attached text:=Agent Name:")
Set Login_Edit_Password=CreateObjectDescription("nativeclass:=Edit,attached text:=Password:")
Set Login_Btn_OK=CreateObjectDescription("nativeclass:=Button,text:=OK")

'Flight Reservation Window

Public Const FlightReservation_Window="text:=Flight Reservation"
Public Const FlightReservation_Menu= "menuobjtype:=2"
Public Const FlightReservation_OpenOrder_Menu="File;Open Order..."
Public Const FlightReservation_NewOrder_Menu="File;New Order"

Set FlightReservation_Obj_DateOfFlight= CreateObjectDescription("nativeclass:=MSMaskWndClass,attached text:=Date of Flight:")
Set FlightReservation_Cmb_FlyFrom= CreateObjectDescription("nativeclass:=ComboBox,attached text:=Fly From:")
Set FlightReservation_Cmb_FlyTo= CreateObjectDescription("nativeclass:=ComboBox,attached text:=Fly To:")
Set FlightReservation_Btn_Flight= CreateObjectDescription("nativeclass:=Button,text:=FLIGHT")
Set FlightReservation_Edit_Name=CreateObjectDescription("nativeclass:=Edit,attached text:=Name:")
Set FlightReservation_Edit_Tickets=CreateObjectDescription("nativeclass:=Edit,attached text:=Tickets:")
Set FlightReservation_Rdb_Class=CreateObjectDescription("nativeclass:=Button,text:=First")
Set FlightReservation_Btn_InsertOrder= CreateObjectDescription("nativeclass:=Button,text:=&Insert Order")
Set FlightReservation_Btn_UpdateOrder= CreateObjectDescription("nativeclass:=Button,text:=&Update Order")
Set FlightReservation_Btn_DeleteOrder= CreateObjectDescription("nativeclass:=Button,text:=&Delete Order")
Set FlightReservation_Edit_OrderNo=CreateObjectDescription("nativeclass:=Edit,attached text:=Order No:")

'Select Flights Dialog

Public Const FlightReservation_Dialog_FlightsTable= "text:=Flights Table"

Set FlightsTable_Lst_FlightList= CreateObjectDescription("nativeclass:=ListBox,attached text:=From")
Set FlightsTable_Btn_OK= CreateObjectDescription("nativeclass:=Button,text:=OK")

'Open Order Dialog

Public Const FlightReservation_Dialog_OpenOrder="text:=Open Order"

Set OpenOrder_ChkBtn_OrderNo=CreateObjectDescription("nativeclass:=Button,text:=&Order No.")
Set OpenOrder_Btn_OK=CreateObjectDescription("nativeclass:=Button,text:=OK")
Set OpenOrder_Edit_OrderNo=CreateObjectDescription("nativeclass:=Edit,window id:=1016")

'Flight Reservation Popup Dialog
Public Const FlightReservations_PopupDialog="text:=Flight Reservations"
Set FlightReservations_Btn_YES= CreateObjectDescription("nativeclass:=Button,text:=&Yes")

''*******************************************************************************
'Object Description Constants End
'*******************************************************************************

'#############################################################################
'Main Script Start
'#############################################################################
'Open Application
Call OpenApplication (ApplicationPath)

'Login
Call Login("Mercury","Mercury")

'Insert an Order
OrderInserted=InsertOrder()

'Open Inserted Order
Call OpenOrder(OrderInserted)

'Delete Inserted Order
Call DeleteOrder (OrderInserted)

'Close Application
Call CloseApplication()

'#############################################################################
'Main Script End
'#############################################################################

'Functions Start
'*******************************************************************************
Function OpenApplication(AppPath)
    InvokeApplication AppPath
End Function
'*******************************************************************************
'*******************************************************************************
Function Login(iUserName,iPassword)

Dialog(Login_Dialog).WinEdit(Login_Edit_AgentName).Set iUserName
Dialog(Login_Dialog).WinEdit(Login_Edit_Password).Set iPassword
Dialog(Login_Dialog).WinButton(Login_Btn_OK).Click

If err.Description="" Then
    Reporter.ReportEvent micPass,"Login","Login Successful"
Else
    Reporter.ReportEvent micFail,"Login","Login Failed"
End If
End Function
'*******************************************************************************
'*******************************************************************************
Function InsertOrder()

Window(FlightReservation_Window).WinMenu(FlightReservation_Menu).Select FlightReservation_NewOrder_Menu
Window(FlightReservation_Window).WinObject(FlightReservation_Obj_DateOfFlight).Type "111111"
Window(FlightReservation_Window).WinComboBox(FlightReservation_Cmb_FlyFrom).Select "Denver"
Window(FlightReservation_Window).WinComboBox(FlightReservation_Cmb_FlyTo).Select "Frankfurt"
Window(FlightReservation_Window).WinButton(FlightReservation_Btn_Flight).Click
Window(FlightReservation_Window).Dialog(FlightReservation_Dialog_FlightsTable).WinList(FlightsTable_Lst_FlightList).Select 0
Window(FlightReservation_Window).Dialog(FlightReservation_Dialog_FlightsTable).WinButton(FlightsTable_Btn_OK).Click
Window(FlightReservation_Window).WinEdit(FlightReservation_Edit_Name).Set "TEST NAME"
Window(FlightReservation_Window).WinEdit(FlightReservation_Edit_Tickets).Set 10
Window(FlightReservation_Window).WinRadioButton(FlightReservation_Rdb_Class).Set
Window(FlightReservation_Window).WinButton(FlightReservation_Btn_InsertOrder).Click
Window(FlightReservation_Window).WinButton(FlightReservation_Btn_DeleteOrder).WaitProperty "enabled",true,10000
InsertOrder=Window(FlightReservation_Window).WinEdit(FlightReservation_Edit_OrderNo).GetROProperty("text")

If err.Description="" Then
    Reporter.ReportEvent micPass,"Insert Order","Order Inserted Successfully"
Else
    Reporter.ReportEvent micFail,"Insert Order","Failed in Inserting an Order"
End If

End Function

'*******************************************************************************
'*******************************************************************************
Function OpenOrder(OrderNumber)

Window(FlightReservation_Window).WinMenu(FlightReservation_Menu).Select FlightReservation_OpenOrder_Menu
Window(FlightReservation_Window).Dialog(FlightReservation_Dialog_OpenOrder).WinCheckBox(OpenOrder_ChkBtn_OrderNo).Set "ON"
Window(FlightReservation_Window).Dialog(FlightReservation_Dialog_OpenOrder).WinEdit(OpenOrder_Edit_OrderNo).Set OrderNumber
Window(FlightReservation_Window).Dialog(FlightReservation_Dialog_OpenOrder).WinButton(OpenOrder_Btn_OK).Click

If err.Description="" Then
    Reporter.ReportEvent micPass,"Open Order","Order Opened Successfully"
Else
    Reporter.ReportEvent micFail,"Open Order","Failed in Opening an Order"
End If

End Function
'*******************************************************************************
'*******************************************************************************
Function DeleteOrder(OrderNumber)

Call OpenOrder(OrderNumber)

Window(FlightReservation_Window).WinButton(FlightReservation_Btn_DeleteOrder).Click
Window(FlightReservation_Window).Dialog(FlightReservations_PopupDialog).WinButton(FlightReservations_Btn_YES).Click

If err.Description="" Then
    Reporter.ReportEvent micPass,"Delete Order","Order Deleted Successfully"
Else
    Reporter.ReportEvent micFail,"Delete Order","Failed in Deleting an Order"
End If

End Function
'*******************************************************************************
'*******************************************************************************

Function CloseApplication()
    Window(FlightReservation_Window).Close
    If err.Description="" Then
        Reporter.ReportEvent micPass,"Close Application","Application Closed Successfully"
    Else
        Reporter.ReportEvent micFail,"Close Application","Failed in Closing the Application"
    End If
End Function

'*******************************************************************************
'*******************************************************************************
Function CreateObjectDescription(StrProperties)

    Dim objDescription
    Dim ObjArr
    Dim PropCount
    Dim ObjProperty
   
    Set objDescription=Description.Create

    ObjArr=split(StrProperties,",")
   
    For PropCount=0 to ubound(ObjArr)
        ObjProperty=split(ObjArr(PropCount),":=")
        objDescription(ObjProperty(0)).value=ObjProperty(1)
    Next
   
  Set CreateObjectDescription=objDescription

End Function

'*******************************************************************************
'Functions End
'*******************************************************************************