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"
brw("CreationTime").Value=0
wait(2)

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

Browser(brw).Close

' Way 2 :
Function ClearCookies()
SystemUtil.Run "Control.exe","inetcpl.cpl"
Set objShell = CreateObject("Wscript.Shell")
Do Until Success = True
Success = objShell.AppActivate("Internet Properties")
Wait(1)
Loop
objShell.Sendkeys "%i"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(1)
objShell.Sendkeys "%f"
Wait(1)
objShell.Sendkeys "%d"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(4)
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: http://msdn.microsoft.com/library/en-us/winprog/winprog/windows_api_start_page.asp?frame=true
A reference to specific API functions can be found at: http://msdn.microsoft.com/library/en-us/winprog/winprog/windows_api_reference.asp?frame=true
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:
Window("HWND:="&hWnd).Close
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_ENABLEDPOPUP 6
#define GW_MAX 6
Example
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
‘Notepad.exe
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
objFile.Close
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")
y=x.popup(boxcontent,2,msgboxtitle,4+32)
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:
Reporter.RunStatus
For Example:
if Reporter.RunStatus = 0 then

flag=1;
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 (http://www.download.com/PrimoPDF/3000-10743_4-10264577.html?part=dl-10264577&subj=dl&tag=button) from PrimoPDF (http://www.primopdf.com/)
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).

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.

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"
wait(3)
WshShell.SendKeys "~"
wait(3)
WshShell.SendKeys "*3"
wait(3)
WshShell.SendKeys "~"
wait(3)

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

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.

Example:

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")
temp=split(x,chr("34"))
ToolTip=temp(1)
msgbox ToolTip