Friday, April 30, 2010

Capturing Bitmap When Text Is Mismatched

Whenever a text in a webpage is mismatched, you may use QTP report event to report the failure.
You can try the below snippet along with report event, the code captures and highlights the mismatched text in the webpage.
Set obj=Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("LABEL")(0)
vStrActualText= obj.innerText
vStrExpectedText="The Web"
If vStrActualText<>vStrExpectedText Then
obj.innerHTML=""&vStrActualText&""
Browser("name:=Google").Page("title:=Google").highlight
Browser("name:=Google").Page("title:=Google").CaptureBitmap "C:\TEST.PNG",True
obj.innerHTML=vStrActualText
End If
If your text is mismatched in the webpage, the script captures bitmap of the page.

No comments:

Post a Comment