QTP Scripting for BEGINNERs

Hi ,
Hope some of you might faced the below question among urself or from others while working with Quick Test Pro.

"How could we know which scripting language is been used currently in QTP ?"

Well, it sounds a bit easy to look at this question and I do hope some of us knew the answer already.

For the folks who doesn't know , Here we go !!!
Use the below Built-In functions :
ScriptEngine --> Returns a string representing the scripting language in use.
ScriptEngineMinorVersion --> Returns minor version # of scripting engine in use.
ScriptEngineMajorVersion--> Returns major version # of the scripting engine in use
ScriptEngineBuildVersion --> Returns build version # of the scripting engine in use.

Copy the below code & paste it into Expert view & execute and see !!!
Code:
Msgbox "Script Engine currently running is : "&ScriptEngine
Msgbox "its minor version is : "&ScriptEngineMinorVersion
Msgbox "its major version is : "&ScriptEngineMajorversion
Msgbox "its Build Version is : "&ScriptEngineBuildVersion

QTP Version History

Hi All,
Belated Happy New Year to you all :):)

Here I would like to share the version history of Quick Test Pro .
1998 -> Astra QT
2000 -> QTP 5.0
2001 -> QTP 5.5
2002 -> QTP 6.0
2003 -> QTP 6.5
2004 -> QTP 8.0
2005 -> QTP 8.2
2006 Feb -> QTP 9.0
2007 Jan -> QTP 9.1
2007 Feb -> QTP 9.2
2008 Jan -> QTP 9.5
2009 Feb -> QTP 10






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.



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:
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")

Output:



























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.



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.

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 :






QTP - Testing Process


Here iam providing the Pictorial view of the Testing Process of the QTP.


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:
Reporter.RunStatus
For Example:
if Reporter.RunStatus = 0 then
flag=1;
end if
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).

Workaround:
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.

Workaround:
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.)
Workaround:
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.)

Work-around:
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.
Work-around:
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.
Work-around:
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.
Work-around:
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.




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.






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
Next
Next

Output :







No comments:

Post a Comment