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.

Saturday, April 17, 2010

Finding Disabled Radio Buttons

The below snippet finds disabled radio button from a webradiogroup using DOM.
Set obj= Browser("name:=Google").Page("title:=Google").Object.getElementsByName("meta")
For i=0 to obj.Length-1
If obj(i).Type="radio" and obj(i).Disabled="True" Then
Msgbox "Radio " &i+1& " is disabled" 'This msgbox indicates the disabled radio button.
End if
Next

Changing Screen Resolution at Runtime

So far I have not found a code for changing screen resolution at runtime using vb script. If anyone finds that, please post it.

An alternative solution, we can go for third party tool like Qres and MultiRes. These tools can be operated using QTP at runtime.

Download Links:
Qres:
http://home.no/aksoftware/
MultiRes: http://www.entechtaiwan.com/util/multires.shtm

If you know any other tool(s), please don’t hesitate to include in the comment section.