Tuesday, December 28, 2010

How to campare two excel sheets in QTP ???

This code will open two excel sheet and compare each sheet cell by cell, if any changes there in cells , it will highlight the cells in red color  in the first sheet.

Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:Documents andSettingsmohan.kakarlaDesktopDocs1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:Documents and

Settingsmohan.kakarlaDesktopDocs2.xls”)
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
   For Each cell In objWorksheet1.UsedRange
       If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
           cell.Interior.ColorIndex = 3′Highlights in red color if any changes in cells
       Else
           cell.Interior.ColorIndex = 0
       End If
   Next

set objExcel=nothing

Please let me know if any question/suggestion.
Thanks,
Shahadat Khan

How to Capture text in QTP

We can use GetROProperty method to retrive runtime values inside an
object.


IF your application is web based..
runtimeValue=Browser("X").Page("X").WebEdit("x").GetROProptery("name of the
property which value you want to retrive").. if you retrieve "innertext" property it will be fine
for that use GUI spy..

Please let me know if any question/suggestion.......

How to Capture a snapshot into Result Summary

We use captureBitmap method for the same, however file name extension should be .png or .bmp.
this is the syntex for capturing the snap shot and display into the result summary. Please let me know if any question/ suggestion

MyFile="ErrorFile.png"
Browser("").Page("").CaptureBitmap MyFile,True
Reporter.ReportEvent micPass,"Out of Sequence Endorsement Snap","The Step Description is",MyFile