tag:blogger.com,1999:blog-2249626713795150612024-03-13T10:25:18.334+05:30HP's QTPThis blog contains QTP FAQs and QTP & Testing Interview Questions.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.comBlogger199125tag:blogger.com,1999:blog-224962671379515061.post-5219510482864555342013-03-17T16:25:00.001+05:302013-03-17T16:25:50.962+05:30How to compare two images using QTPWe know by using Bitmap checkpoint, we can compare two images.<br />
<br />
But is there a other way we can compare?<br />
<br />
Yes, we can use "IsEqualBin" method from Mercury.FileCompare<br />
<br />
sImgPath1="C:\Users\user\Downloads\SAI 01461_exposure.JPG"<br />'sImgPath2="C:\Users\user\Downloads\SAI 01462_exposure.JPG"<br />sImgPath2="C:\Users\user\Downloads\SAI 0175_exposure.JPG"<br />Set obj=createobject("Mercury.FileCompare")<br />retVal=obj.IsEqualBin(sImgPath1,sImgPath2,1,1)<br />print retVal<br />Set obj=nothing<br />
<br />
The retVal=1 if both the images are same<br />
else retVal=0Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com9tag:blogger.com,1999:blog-224962671379515061.post-72515224605608211182013-03-04T22:46:00.001+05:302013-03-04T22:46:39.792+05:30How to add an image at the end of the Word documentHere i divided the task into 2 steps.<br />
1. Capture the desktop image/application.<br />
2. Insert the captured image at the end of the word document.<br />
<br />
sImageFilePath="D:\TempImage.png"<br />sWordFilePath="D:\Programming Samples\QTP\SampWord.docx"<br /><br />CapturePrintScreen sImageFilePath<br />AddImageToWord sWordFilePath,sImageFilePath<br /><br />Sub CapturePrintScreen(sFilePath)<br /> Desktop.CaptureBitmap sFilePath,true<br />End Sub<br /><br />Sub AddImageToWord(sWrdFilePath,sImgFilePath)<br /> Const END_OF_STORY = 6<br /> Const MOVE_SELECTION = 0<br /> Set oWord=createobject("Word.Application")<br /> oWord.Visible=true<br /><br /> set oDoc=oWord.Documents.Open(sWrdFilePath)<br /><br /> Set oSelection=oWord.Selection<br /> oSelection.EndKey END_OF_STORY,MOVE_SELECTION<br /><br /> oSelection.InlineShapes.AddPicture(sImgFilePath)<br /><br /> oDoc.Save<br /><br /> oWord.Application.Quit<br />
<br />
Set oWord=nothing<br />End SubAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-89903761967399822972013-02-07T00:15:00.001+05:302013-02-07T00:15:52.145+05:30QTP unables to identify pop up window<br />
There are couple of scenarios where we perform some operations in a application, where a pop up window will appear like:<br />
1. When you delete a user/emp, it will display a pop up saying "Do you want to Delete the user?"<br />
2. You choose some pop up menu option, then a pop up window may be displayed with the selected items functionality.<br />
<br />
For sometimes, even though you have the correct recorded script, it may throw you an error saying the object does not exist.<br />
<br />Ex: B("XYZ").Dialog("Delete User").WinButton("Ok").click may throw error saying "Object not visible".<br />
<br />
How to overcome this error?<br />
<br />
Cause: The "visible" property of the Parent object may not enabled.<br />
<br />
Solution: Goto Tools -> Object Identification -> Choose Environment type -> Choose the object class(in our case Browser is the parent to the Dialog box) -> Click on Add/Remove property -> select "visible" property.<br />
After visibility property is configured, now re-record the steps.<br />
<br />
Now QTP should be able to identify the pop up window. Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com2tag:blogger.com,1999:blog-224962671379515061.post-66281418493856131412013-02-05T20:47:00.001+05:302013-02-05T20:47:48.655+05:30How to get QTP Results in a HTML fileOnce we ran our Regression suite, it is handy if the results are displayed in HTML File, it is easy for us to understand at the same time also easy for the management(Lead/Manager/Customer) to look at it.<br />
<br />
They will not show any interest if you zip your QTP Result folders and send it to them.<br />
<br />
And for many reasons it is handy if the results are displayed in HTML File, right? How can we get the results in HTML File.<br />
<br />
But how can we view results in HTML File?<br />
<br />
By changing one registry setting, we have get QTP results in a HTML File.<br />
<br />
Open windows registry by entering regedit and clicking enter in Windows run.<br />
<br />
HKLM\Software\MercuryInteractive\QuickTestProfessional\Logger\Media\Log<br />
<br />
Double click on "Active"<br />
<br />
Change the value from 0 to 1.<br />
<br />
Restart QTP. <br />
<br />
Now run your QTP Test and see results in the QTP Test folder, where you see a "Log" folder.<br />
<br />
In this folder you will see a file called LogFile.html which is the HTML Report.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-45287656562489965952013-02-01T22:57:00.000+05:302013-02-01T22:57:07.634+05:30How to check the website you are testing is up and runningWe can check the website up and running by just pinging the website.<br />
<br />
You can do that in couple of ways.<br />
<br />
Here is the simplest way to ping a website.<br />
<br />
<u><b>Appraoch1:</b></u><br />
<br />
strWebSiteName="www.yahoo.com"<br />strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & strWebSiteName & "'"<br />bFlag = False<br /><br />Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")<br />Set objItems = objWMIService.ExecQuery( strQuery )<br /><br />For Each objItem In objItems<br /> If objItem.StatusCode = 0 Then<br /> bFlag = True<br /> Exit For<br /> Else<br /> bFlag = False<br /> End If<br />Next<br /><br />If bFlag = true Then<br /> print "Website is avilable"<br />else<br /> print "Website not avilable"<br />End If<br /><br />Set objItems = Nothing<br />Set objWMIService = Nothing<br /><br /><u><b>Appraoch2:</b></u><br />Set oNetwork = DotNetFactory( "Microsoft.VisualBasic.Devices.Network" ,"Microsoft.VisualBasic")<br />bFlag=oNetwork.ping(strWebSiteName)<br />If bFlag Then<br /> print "Website is avilable" <br />Else<br /> print "Website not avilable" <br />End If<br />Set oNetwork=nothing<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com4tag:blogger.com,1999:blog-224962671379515061.post-34845857001620277252013-01-19T17:23:00.002+05:302013-01-19T17:23:43.238+05:30How to check an Excel file is already openThere are no direct methods using Exel/Workbook object to find the functionality.<br />
<br />
Work around is, we need to find out all open tasks, and from that we will see whether any task with name "Microsoft Excel"<br />
<br />
Here in the below code, i have a sample Excel file with name "SampleXL".<br />
<br />
Set Word = CreateObject("Word.Application")<br />Set Tasks = Word.Tasks<br />i=0<br />For Each Task in Tasks<br /> If instr(Task.Name,"Microsoft Excel - SampleXL")>0 Then<br /> i=1<br /> end if<br />Next<br />If i=1 Then<br /> print "Excel file is opened"<br />else<br /> print "No excel file opened with the name specified"<br />End If<br /><br />Word.Quit<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com1tag:blogger.com,1999:blog-224962671379515061.post-74548890366742050132013-01-19T16:59:00.000+05:302013-01-19T16:59:30.266+05:30How to retrieve data from Excel file using ADODBThe below code retrieves data from Sheet1 from an Excel file using ADODB.<br />
<br />
Both the connection strings specified here works.<br />
<br />
Set oCmd=createobject("ADODB.Command")<br />Set oRS=createobject("ADODB.RecordSet")<br /><br />sCon="Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=D:\Programming Samples\QTP\SampleXL.xls;"<br />'sCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Programming Samples\QTP\SampleXL.xls;Extended Properties=""Excel 8.0;"""<br />sQry="select * from [Sheet1$]"<br /><br />oCmd.ActiveConnection = sCon<br />oCmd.CommandText=sQry<br />Set oRS=oCmd.Execute<br />While not oRS.EOF<br /> print oRS.Fields(1).Value<br /> oRS.MoveNext<br />Wend<br /><br />oRS.Close<br /><br />Set oCmd=nothing<br />Set oRS=nothing<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-32549483699367265612013-01-19T13:23:00.001+05:302013-01-19T13:23:42.577+05:30How to verify the existance of an environmental variableThe below code illustrate the existence of an environmental variables:<br />
<br />
function checkEnvironmentalVariableExists(sEnvVarName)<br /> Err.clear<br /> On error resume next<br /> envValue=Environment.Value(sEnvVarName) 'Env exist<br /> If Err.number<>0 Then<br /> checkEnvironmentalVariableExists=False<br /> else<br /> checkEnvironmentalVariableExists=true<br /> End If<br /> On error goto 0<br />end function<br /><br />Environment.Value("name")="Uday"<br />retVal=checkEnvironmentalVariableExists("name123")<br />If retVal=true Then<br /> print "Environmental Variable exists"<br />else<br /> print "Environmenta Variable does not exist"<br />End If<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-38878038361504606512013-01-01T13:43:00.002+05:302013-01-01T13:43:28.638+05:30How to check a browser window is minimizedExtern.Declare micLong, "GetMainWindow", "user32" ,"GetAncestor",micLong, micLong 'This is the declaration for the referencing "GetMainWindow" with the GetAncestor method in user32.dll.<br />GA_ROOT=2<br />
<br />
Just opened Gmail and checked whether the browser is minimized or maximized.<br />
<br />
We cannot directly use Browser().GetROProperty("minimized") here.<br />
<br />
<br />
Set oBrowser=description.Create<br />oBrowser("micclass").value="Browser"<br />oBrowser("name").value="Gmail.*"<br /><br />hwnd=Browser(oBrowser).GetROProperty("hwnd")<br /><br />hwnd = Extern.GetMainWindow(hwnd , GA_ROOT)<br />msgbox Window("hwnd:=" & hwnd ).GetROProperty("minimized") <br />
<br />
The above code returns False if the Tab/browser is maximized else<br />
returns True if the Tab/browser is minimized<br />
<br />
The above code worked well with QTP and IE 7.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-69041130405258972282013-01-01T12:02:00.001+05:302013-01-01T12:02:18.629+05:30How to display occurances of a string in a Excel fileFollowing code helps find the occurrences of a string in a Excel file.<br />
<br />
It will return the count as 0, if the string is not found<br />
else returns the number of occurrences of the string<br />
<br />
Dim oXLObj,oXLWBObj,olXLWSObj<br /><br />Function FindStringOccuranceCount(sFileName,iSheetId,sSearchString)<br /> iCount=0<br /> set oXLObj=createobject("Excel.Application")<br /> Set oXLWBObj=oXLObj.workbooks.open(sFileName)<br /> Set olXLWSObj=oXLWBObj.worksheets(1)<br /><br /> set cell=olXLWSObj.Range("A:Z").find(sSearchString)<br /> <br /><br /> If cell is nothing Then<br /> CloseExcel()<br /> FindStringOccuranceCount=iCount<br /> Exit Function<br /> End If<br /><br /> sFirstAddress=cell.address<br /><br /> Do<br /> set cell=olXLWSObj.Range("A:Z").FindNext(cell)<br /> 'set CurCell=olXLWSObj.UsedRange.FindNext(sSearchString)<br /> sCurrentAddress=cell.address<br /> 'sCurrentAddress<br /> iCount=iCount+1<br /> loop while not cell is nothing and sCurrentAddress<>sFirstAddress<br /><br /> CloseExcel()<br /> FindStringOccuranceCount=iCount<br /><br />End Function<br /><br />Function CloseExcel()<br /> oXLWBObj.close<br /> oXLObj.application.quit<br /> Set oXLWBObj=nothing<br /> Set oXLObj=nothing<br />End Function<br /><br />x=FindStringOccuranceCount("C:\Test1.xls",1,"Uday")<br />msgbox x<br /><br />Sample Excel file is here:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-PEn7dOGy7BY/UOKCX2tRzVI/AAAAAAAAMR4/GPm-YUneqpA/s1600/XL.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="348" src="http://4.bp.blogspot.com/-PEn7dOGy7BY/UOKCX2tRzVI/AAAAAAAAMR4/GPm-YUneqpA/s640/XL.JPG" width="640" /></a></div>
<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-59407246018779718902012-12-19T23:03:00.000+05:302012-12-19T23:03:16.217+05:30QTP built-in environmental variablesI found people forget the all the built-in environmental variables, so thought of putting all built-in variables here in this post.<br />
<br />
ActionIteration - Indicates which action iteration is currently running.<br />
ActionName - Indicates which action is currently running<br />
ControllerHostName - the name of the computer which serves as a controller<br />
GroupName - The scenario identification number<br />
LocalHostName - Local Host Name<br />
OS - Operation System<br />
OSVersion - Operating system version<br />
ProductDir - folder path where the product is installed<br />
ProductName - Product Name<br />
ProductVer - Product Version<br />
ResultDir - Folder path where the results are saved<br />
Scenarioid - The scenario identification number<br />
SystemTempDir - System Temporary Directory<br />
TestDir - Path of the Test<br />
TestIteration - Indicates which test iteration is currently running<br />
TestName - The name of the test<br />
UpdatingActiveScreen -<br />
UpdatingCheckpoints -<br />
UpdatingTODescriptions -<br />
UserName - Windows Login User Name<br />
VUserId - Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-46291133483887633832012-11-09T08:09:00.000+05:302012-11-09T08:09:04.224+05:30How to find CPU and Memory Usage using QTPHow to find out CPU utilization and Memory usage as displayed in the Windows Task Manager.<br />
<br />
We can get these values using WMI service.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-15ls6HIIJsg/UJxru0Cpz8I/AAAAAAAALwQ/tLyB0ps3RaM/s1600/Task+Manager.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-15ls6HIIJsg/UJxru0Cpz8I/AAAAAAAALwQ/tLyB0ps3RaM/s320/Task+Manager.JPG" width="267" /></a></div>
<br />
Below is the code:<br />
strComputer = "."<br />Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")<br /><br />'Get the CPU utilization %<br />myQuery = "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'"<br />For Each objItem in objWMIService.ExecQuery(myQuery)<br /> print "Processor time " & objItem.PercentProcessorTime & " %"<br />next<br /><br />'Get the total Physical Memory<br />myQuery="Select * from Win32_ComputerSystem"<br />Set colItems = objWMIService.ExecQuery(myQuery)<br />For each objitem in colItems<br /> print "Total Physical Memory "&objitem.TotalPhysicalMemory/1024<br />Next<br /><br />'Get the total available physical memory<br />myQuery="Select * from Win32_PerfFormattedData_PerfOS_Memory"<br />Set colItems = objWMIService.ExecQuery(myQuery)<br />For Each objItem in colItems<br /> print "Available GB: " & objItem.AvailableKBytes<br />Next<br /><br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-15241164238646950052012-11-07T23:44:00.000+05:302012-11-08T20:57:42.652+05:30How to execute QTP scripts in a remote machine when the window is minimized?QTP Version : 11 or later<br />
RDP Version : 6 or later<br />
<br />
If you want to run QTP scripts run on a remote machine and if that Remote machine/Window is minimized, then the scripts will fail.<br />
<br />
In order to overcome the issue, you need to add a registry key in Windows registry on your client machine/from the machine where you initiating the remote desktop.<br />
1. Close all your remote desktops.<br />
2. Create a registry "RemoteDesktop_SuppressWhenMinimized" if does not exist in the below path:<br />
HKEY_CURRENT_USER\Software\Microsoft\Terminal ServerClient\RemoteDesktop_SuppressWhenMinimized<br />
or<br />
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Terminal Server Client\RemoteDesktop_SuppressWhenMinimized<br />
3. Set the value for this data to 2.<br />
<br />
If you would like to add the registry key by just running a .reg file follow below steps:<br />
1. Open Notepad.<br />
2. Cope the below content:<br />
Windows Registry Editor Version 5.00<br /><br />[HKEY_CURRENT_USER\Software\Microsoft\Terminal ServerClient\RemoteDesktop_SuppressWhenMinimized]<br />"RemoteDesktop_SuppressWhenMinimized"=dword:00000002<br /><br />[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Terminal Server Client\RemoteDesktop_SuppressWhenMinimized]<br />"RemoteDesktop_SuppressWhenMinimized"=dword:00000002<br />
3. Save the file as "FileName.reg" format<br />
4. Now, double click on this reg file, so that registry keys will be added.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-83111827690768543652012-07-28T12:16:00.002+05:302012-07-28T12:16:41.799+05:30How to activate, minimize, maximize a browser using QTPYou can use below code to active, minimize, maximize a browser. I put all these three methods in a single function, but you need to tweek this code as per your needs.<br />
<br />
Function WinActivate(Object)<br /> Dim hWnd<br /> hWnd = Object.GetROProperty("hwnd") 'First get the window handle<br /> On Error Resume Next<br /> Window("hwnd:=" & hWnd).Activate 'Put fouse on the window<br /> If Err.Number <> 0 Then<br /> hWnd=Browser("hwnd:=" & hWnd).Object.hWnd 'now get the browser handle<br /> Window("hwnd:=" & hWnd).Activate <br /> 'Window("hwnd:=" & hWnd).minimize 'To minimize the browser<br /> 'Window("hwnd:=" & hWnd).maximize<br /> Err.Clear<br /> End If<br /> On Error Goto 0<br />End Function<br />
<br />RegisterUserFunc "Browser","Activate","WinActivate"<br />RegisterUserFunc "Browser","Minimize","WinMinimize"<br />RegisterUserFunc "Browser","Maximize","WinMaximize"<br /><br />Browser(objBrowser).Activate<br />Browser(objBrowser).Minimize<br />Browser(objBrowser).MaximizeAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-26986066856989977222012-06-30T21:18:00.000+05:302012-06-30T21:23:41.693+05:30How to verify a Browser Window is minimizedThe bad part is QTP does not support retrieving RO Properties of a browser.
If it has supported, then we would have use a method like
Browser("Browser Name").GetROProperty("minimized")
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-4UcPNggvtjg/T-8fJ3BZ7fI/AAAAAAAALuk/QRc0tZ_wd0w/s1600/Window+Minimized.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-4UcPNggvtjg/T-8fJ3BZ7fI/AAAAAAAALuk/QRc0tZ_wd0w/s320/Window+Minimized.JPG" width="185" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
But we can use Extern to use some of the methods from Windows user32.dll<br />
Following are the two ways to verify the window minimized.<br />
Extern.Declare micHwnd, "FindWindow", "user32.dll","FindWindowA", micString,micString 'this method returns a handle<br />
Extern.Declare micLong,"GetWindowMinimizeState", "user32.dll" ,"IsZoomed",micLong 'IsZoomed meaning IsMaximized<br />
hwnd=extern.FindWindow(NULL,"Links - Windows Internet Explorer")<br />
print Extern.GetWindowMinimizeState(hwnd)
'Similar way<br />
<br />
<br />
Const GA_ROOT = 2<br />
'Declare Function GetAncestor Lib "user32.dll" (ByVal hwnd As Long, ByVal gaFlags As Long) As Long
Extern.Declare micLong, "GetMainWindow", "user32" ,"GetAncestor",micLong, micLong<br />
hwnd = browser("name:=Links.*").GetROProperty("hwnd") 'this returns the handle of the Browser Tab
hwnd = Extern.GetMainWindow(hwnd , GA_ROOT) 'This returns the handle of the browser(which means handle of the browser)<br />
msgbox Window("hwnd:=" & hwnd ).GetROProperty("minimized")Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-30662666627626585422012-06-30T16:26:00.001+05:302012-06-30T16:26:25.060+05:30How to find and fill a color in Excel CellSet xlObj=getobject("","Excel.Application")<br />Set xlWBObj=xlObj.workbooks.open("c:\delete.xls")<br />set xlWSObj=xlWBObj.worksheets(1)<br />xlWSObj.cells(1,1).Font.Color=vbRed 'This statement changes the color of the Text in the specified cell<br />xlWSObj.cells(2,1).Interior.ColorIndex=4 'This method changes the color of the background of the cell<br />print xlWSObj.cells(1,1).Font.Color<br />print xlWSObj.cells(2,1).Interior.ColorIndex<br />xlWBObj.save<br />xlWBObj.close<br />xlObj.application.quit<br />Set xlObj=nothing<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-24486727377231268572012-04-30T12:11:00.001+05:302012-05-22T09:46:41.305+05:30How to copy content to ClipboardWe can use clipboard using two ways.<br />
One is using Mercury.Clipboard.<br />
Second one is using DotNetFactory.<br />
<br />
<br />
Using Mercury.Clipboard:<br />
'Creates an instance of Mercury.Clipboard<br />
set objCB=createobject("Mercury.Clipboard")<br />
'Here i am clearing already existing content in clipboard<br />
objCB.Clear()<br />
'Copying some text into Clipboard<br />
objCB.SetText("Hello Uday")<br />
'Retrieving the content from Clipboard<br />
print objCB.GetText<br />
<br />
Using DotNetFactory:<br />
'Creates an instance of DotNetFactory Computer Object<br />
Set objDFComputer=DotNetFactory("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")<br />
'Here i am clearing already existing content in clipboard<br />
Set objCB=objDFComputer.ClipBoard<br />
objCB.clear()<br />
'Copying some text into Clipboard<br />
objCB.SetText("Hello Uday")<br />
'Retrieving the content from Clipboard<br />
print objCB.GetTextAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com1tag:blogger.com,1999:blog-224962671379515061.post-28055918392332366762012-04-29T13:13:00.000+05:302012-04-29T15:12:14.782+05:30"Setting" utility object to access registry valuesWe can obtain and configure all the QTP configurable parameters(all parameters in <b>MicTest</b>) using "Setting" utility object. Ex: BrowserType, DefaultLoadTime etc...<br />
For Ex: If you want to retrieve the default location of saving your tests, which exists in HKLM\Software\Mercury Interactive\QuickTest Professional\MicTest\TestsDirectory, you can use below line of code:<br />
Setting<br />
<b><span style="color: #cc0000;">print Setting("TestsDirectory")</span></b><br />
<br />
You can also use Setting.Item to retrieve the value of the parameter. For the above, you can also use like:<br />
<b style="color: #cc0000;">print Setting.Item("TestsDirectory")</b> <br />
<br />
If you want to access a parameter exists in folders, then you can use<br />
Setting("")("Child1")("Child2)("PropertyName")<br />
<br />
Here is the Ex. to access the Add-In Manager name for Visual Basic.<br />
<b style="color: #cc0000;">print Setting("AddIn Manager")("VisualBasic")("Name")</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-V6xNebqxL2A/T5zwrDhycVI/AAAAAAAALuQ/v37ORca8Tfc/s1600/Setting.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="345" src="http://3.bp.blogspot.com/-V6xNebqxL2A/T5zwrDhycVI/AAAAAAAALuQ/v37ORca8Tfc/s640/Setting.JPG" width="640" /></a></div>
<br />Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-25021221795392014922012-03-15T00:24:00.004+05:302012-03-15T00:38:41.107+05:30Pure virtual function call<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-lg3JgXm4QkA/T2Dr1vfrXLI/AAAAAAAALuA/0OuBuWUDmNg/s1600/g5.JPG"><img style="cursor: pointer; width: 320px; height: 137px;" src="http://4.bp.blogspot.com/-lg3JgXm4QkA/T2Dr1vfrXLI/AAAAAAAALuA/0OuBuWUDmNg/s400/g5.JPG" alt="" id="BLOGGER_PHOTO_ID_5719830835275455666" border="0" /></a><br />Suddenly QTP behaves very strangely. You cannot save any Tests etc etc... and it throws an error message saying R6025 - Pure Virtual Function call. You cannot do much after this error.<br />Reinstalling QTP also less useful.<br /><br />Possible causes might be:<br />QTP configuration files might be corrupt.<br />Not properly handling pointers in QTP, meaning not properly releasing the objects like Excel, ObjectRepository objects etc...<br />QTP provides patch for this. Install the patch<span style="font-weight: bold;"> QTP_00604 </span>or<span style="font-weight: bold;"><span style="font-weight: bold;"> QTP_00626.</span></span><span class="wrapbody"><span style="font-size:85%;"><strong></strong></span></span>Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-28509980843861021582012-03-15T00:09:00.001+05:302012-03-15T00:11:07.900+05:30IE scripts are failing or Objects are not recognized in IE.Scripts are failing when IE is upgraded.<br />User has scripts developed in IE 6 and they worked fine.<br />But user updated his IE to IE7, then the scripts which worked earlier are failing now in IE 7.<br /><br />Reasons could be:<br />BHOManager add-in could be disabled in IE7.<br />This add-in is needed for QTP to interact with IE.<br />Enable this Add-in by:<br />Open IE -> Tools Menu -> Manage Add-ons -> Enable or Disable add-ons -> Select BHOManager Class<br />Check whether the add-on is enabled or not. It should be enabled.<br /><br />Objects are properly recognized in IE 7, but not recognized in IE 8.<br />Reason could be: Protected mode in IE 8.<br />Check the above solution, then follow to disable the protected mode in IE.<br />Open IE -> Tools Menu -> Internet Options -> Security Tab -> Uncheck "Enable Protected Mode" check box.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-86078333860200436462012-03-14T23:30:00.002+05:302012-03-14T23:37:45.115+05:30All menu options are missing in QTPSometime you are strange to see that all menu options are missing in QTP.<br />Ex: File -> Setting etc... You may miss lot of menu options in QTP.<br /><br />Fix:<br />Open QTP -> Tools menu -> Customize -> Click on Toolbars Tab -> Restore All ->click on Close button.<br /><br />If you miss options in Tools Menu, then in QTP right click on the tool bar and choose customize.Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com1tag:blogger.com,1999:blog-224962671379515061.post-23525187116075685662012-03-11T19:22:00.001+05:302012-03-11T19:23:41.357+05:30How to get the source code of a Webpage using QTPprint browser("name:=AAA").page("title:=AAA").Object.documentElement.innerHTMLAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-40068054275602598352012-02-25T11:41:00.003+05:302012-02-25T11:50:55.493+05:30How to find the Memory usage and Processor usage using QTPQTP provides the object called "SystemMonitor" which can be used to get Memory and Processor usage.<br /><br />'To find the Memory usage of an application, use below:<br />SystemMonitor.GetValue("Application name without extension", "counter name")<br />Ex: msgbox SystemMonitor.GetValue("QTPro","Memory Usage (in MB)")<br /><br />'To find the Processor usage of an application, use below:<br />Ex: msgbox SystemMonitor.GetValue("javaw","% Processor Time")Anem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com0tag:blogger.com,1999:blog-224962671379515061.post-52391223043568271972012-02-21T23:58:00.004+05:302012-09-10T09:21:11.487+05:30Right click on a weblink using QTP'The below scripts selects the second pop up item after right clicking on the weblink.<br />
'Open the Yahoo website in IE and execute the script.<br />
'Opens the images webpage(open in new tab) in a new tab<br />
<br />
Setting.WebPackage("ReplayType") = 2<br />
'This statement makes the replay type to Mouse from event. Without this configuration the script may or may not work.<br />
<br />
Set link=browser("Yahoo!").Page("Yahoo!").Link("Images")<br />
link.highlight <br />
index=2<br />
Set obj = CreateObject("Mercury.DeviceReplay")<br />
Set WshShell = CreateObject("WScript.Shell")<br />
<br />
'Get the absolute coordinates of the object<br />
absx = link.GetROProperty("abs_x") <br />
absy = link.GetROProperty("abs_y")<br />
<br />
'Right click on the Object<br />
obj.MouseClick absx+5, absy+5, 2 'Here 2 is for right click<br />
<br />
'Optional wait statement<br />
wait 2<br />
<br />
'Clicking number of downs<br />
For i = 1 To index<br />
WshShell.sendkeys "{DOWN}"<br />
Next<br />
<br />
WshShell.sendkeys "{ENTER}"<br />
<br />
Setting.WebPackage("ReplayType") = 1<br />
<br />
Set WshSEll = nothing<br />
Set obj = nothingAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com1tag:blogger.com,1999:blog-224962671379515061.post-43656576422972124062011-09-30T23:33:00.001+05:302011-09-30T23:35:55.932+05:30Working with Dictionary ObjectSet dictObj=Createobject("Scripting.Dictionary")<br />dictObj.Add "1","One"<br />dictObj.Add "2","Two"<br />dictObj.Add 3,"Three" 'Observe here i am passing key as a integer meaning we can pass different types as Key<br /><br />msgbox dictObj.Count 'This method returns the number of keys<br /><br />If dictObj.Exists(3) Then 'This method looks for the Key<br /> msgbox "Key exists"<br />else<br /> msgbox "Key does not exist"<br />End If<br /><br />a=dictObj.Keys 'This method assigns all the keys to an array<br />For i=1 to dictObj.Count<br /> msgbox dictObj.Item(a(i-1)) 'This method retrieves the value of the key<br />NextAnem Udaya Kumarhttp://www.blogger.com/profile/13520163460208912903noreply@blogger.com1