Está en la página 1de 6

Important Notes on QTP ============================ QTP 10.

0 will work with Windows7 and the patch details are given below Change Request: QC82264 This patch enables you to install and use QuickTest 10.00 on Windows 7 and Windows Server 2008 R2 operating systems. However: 1. Windows 7 and Windows Server 2008 R2 do not support the Windows API test recognition mechanism. Therefore, when you install this patch, the 'Use text recognition mechanisms in this order' option in the Options dialog box (Tools > Options > Text Recognition) is set to 'Use only OCR', and cannot be changed (the option is disabled). 2. To support seat licenses on Windows 7, you must run instdemo.exe from QuickTest's bin directory after installing this patch. (Seat licenses are not supported on Windows Server operating systems.) 3. If you want to test WPF objects, you must also add the following line to the [MicIPC] section of the <WinDir>\mercury.ini file. conhost.exe=0 QTP 10.0 offers additional add-ins for Java, .Net, Oracle, Deplhi, Siebel, Peoplesoft, SAP.

Mouse Action Record through code:


Automate selecting an option on Right Click popup menu. Setting.WebPackage("ReplayType") = 2 ' This lines changes the run mode as Analog object.WebTable("name").FireEvent "onclick",,,micRightBtn ' Rightclicking on the object Set WshShell = CreateObject("WScript.Shell") idx = 15 ' Option number For i = 1 To idx WshShell.sendkeys "{DOWN}" Next WshShell.sendkeys "{ENTER}" Set WshSEll = nothing

Kill process by process name:


KillprocessIE ="EXCEL.EXE" Set ProcessList2 = GetObject("winmgmts://.").InstancesOf("win32_process") For Each Process In ProcessList2 If Process.Name = KillProcessIE Then Process.Terminate End If Next ------------------------------------------------------------------------------------------------------Select option from popup after mouse rightclick: Browser("FX_Browser").Page("FX_Page").WebTable("PERIOD").FireEvent "onclick",,,micRightBtn Set WshShell = CreateObject("WScript.Shell") idx=15 ' Option number For i = 1 To idx WshShell.sendkeys "{DOWN}" 'Navigate to the option Next WshShell.sendkeys "{ENTER}" Set WshSEll = nothing -------------------------------------------------------------------------------------------------------

How to close MsgBox at Runtime


Set sh = CreateObject(Scripting.Shell) This will create a shell object at run-time and will be available until the test ends. If you are getting problem like, Activex Component cant create object then use Set sh = CreateObject(WScript.Shell) Where ever you are having Msgbox replace it with the following code sh.Popup message content, 5, msg header, (0+4) The above line will show the message content for 5 seconds (and vanishes after that). -------------------------------------------------------------------------------------------------------

Unix and Windows File Transfer


Use Wininet.dll to transfer files to/from Unix box Extern.Declare micLong, "InternetOpen", "Wininet.dll", "InternetOpenA", micString, micDWord, micString, micString, micDWord Extern.Declare micLong, "InternetConnect", "Wininet.dll", "InternetConnectA", micLong, micString, micInteger, micString, micString, micDWord, micDWord, micDWord Extern.Declare micInteger, "InternetCloseHandle", "wininet.dll", "InternetCloseHandle", micLong Extern.Declare micInteger, "FtpPutFile", "wininet.dll", "FtpPutFileA",micLong, micString, micString, micDWord Const INTERNET_OPEN_TYPE_DIRECT = 1 Const INTERNET_DEFAULT_FTP_PORT = 21 Const INTERNET_SERVICE_FTP = 1 'Initiate the internet connection objInternet = Extern.InternetOpen("QTP_FTP", INTERNET_OPEN_TYPE_DIRECT, vbNullChar, vbNullChar, 0) If objInternet = 0 Then msgbox "Internet Connection Not Opened" End If 'FTP to server objConnect = Extern.InternetConnect(objInternet, "Server name", INTERNET_DEFAULT_FTP_PORT,"username","password", INTERNET_SERVICE_FTP, 0, 0) If objConnect = 0 Then msgbox "Connected to server" End If local = "Local File Path" remote = "Remote File Path where file needs to be ftp'd" Putfile = Extern.FtpPutFile(objConnect, local , remote, 0 ) If Not CBool( Putfile ) Then Reporter.ReportEvent micFail, "FtpPutFile", "Failed to upload file." End If Extern.InternetCloseHandle(objConnect) Extern.InternetCloseHandle(objInternet)

DeviceReplay Object
The function below uses the DeviceReplay object to perform a right-click operation on any object by retrieving the coordinates of the object. Sub RightClickObj(Obj, Offset_x, Offset_y) x_coord = Obj.GetROProperty("abs_x") y_coord = Obj.GetROProperty("abs_y") Set dr = CreateObject("Mercury.DeviceReplay") dr.MouseClick x_coord + Offset_x, y_coord + Offset_y, 2 End Sub -------------------------------------------------------------------------------------------------------

Script to Lock the Computer after Execution


Set obj = CreateObject("WScript.Shell") sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation" obj.Run sCmnd, 0, False Set obj = Nothing How to Delete Cookies, Delete Browser History, Clear Browser History with QTP Script: VBScript to Delete Cookies *********************** Webutil.DeleteCookies WebUtil object is one of the undocumented object in QTP. Execute the above statement before opening the browser to delete cookies. VBScript to Delete Browsing History ************************** 'Deleting Browsing History, Temporary Files To clear temporary Internet files Set WshShell = CreateObject("WScript.Shell") WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8"

VBScript to Clear Browsing History ************************** To Clear Browsing History WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1" ------------------------------------------------------------------------------------------------------BlockInput Feature QTP provides BlockInput method to prevent keyboard and mouse input events from reaching applications. UnblockInput method re-enables keyboard and mouse input events after a BlockInput statement was used to block them. Here is an example. Test it out! SystemUtil.BlockInput Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "mercury" Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("password").SetSecure "4082986e39ea469e70dbf8c5a29429fe138c6efc" Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("SignIn").Click 2, 2 SystemUtil.UnblockInput ------------------------------------------------------------------------------------------------------Difference between Class Name, micClass, micclass, className When looking through the object spy on any object, we'll see the test-object property "Class Name", which always equals to the QTP-Type of that object. So for example, the Class Name of a browser is "Browser", the Class Name of a WinButton is "WinButton". If you wish to use the "Class Name" property to identify objects with Descriptive Programming syntax, you'd have to use the property micclass. So for example, this won't work: Browser("Class Name:=Browser") But this will: Browser("micclass:=Browser") So, this takes care of Class Name and micclass, what about the plain old Class and className properties? These properties are usually unique to Web objects.

className is a Run-Time object property of Web objects. You can test it yourself: build a symple HTML file, and add to one of the HTML nodes. When you'll load that HTML file in a browser, and use the object spy on the relevant web-object, you'll see className="Something" in the Run-Time tab of the object spy. class is simply the Test-Object property which equals the Run-Time property of className. Meaning that oWebObject.GetROProperty("class") will be the same as oWebObject.Object.className. They represent the same inner data, once through the Run-Time world, and once through the Test-Object world. ------------------------------------------------------------------------------------------------------How to read XML file from QTP? I'm going to show how to parse XML file and read its values from QTP. http://germantechie.com/automation-testing/82-using-xmldom-with-qtp 1. http://go-gaga-over-testing.blogspot.in/2012/04/vapi-script-to-kill-qtp-process.html

También podría gustarte