Friday, August 6, 2010

Checkproperty method in QTP

Checks whether the specified object property achieves the specified value within the specified timeout.

Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])

Eg. 1. Check the status of page.

>Browser("micclass:=Browser prop").Page("micclass:=Page prop").Object.CheckProperty ("status","done",3000)

Eg. 2.Verify the text AutomationTest has been entered on the name textbox.

>Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“name of text box”).Set “AutomationTest”
sCheck=Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“textbox name”).CheckProperty “value”, “AutomationTest”

Monday, November 30, 2009

Check if a particuar text is present on page or not.

In few of scenarios we have to check that text is present on a page or not.

The following function will return True in case if text exists else function will return False.

'Create Page object
set objpage = Browser(“Browser Prop”).Page(“Page Prop”)

'Calling the function
msgbox VerifyTextOnPage(objParent ,”Test” )

Function VerifyTextOnPage(byval objpage , byval Textvalue )
On error resume next
Set oDesc= Description.Create()
oDesc(“micclass”).value=”WebElement”
oDesc(“html tag”).value=”.*[A-Za-z0-9].*”
oDesc(“outertext”).value =”.*[A-Za-z0-9].*”

'Create ALL child object
set collItems= objpage.ChildObjects(oDesc)

'Get all text from web page and store in a variable

For i=1 to collItems.count
OutPutText= OutPutText & collItems.Item(i).GetROProperty(“outertext”)
Next

'compare the text

If instr(1,lcase(OutPutText),lcase(Textvalue)) > 0 Then

' return true if found

VerifyTextOnPage= True
Else
rem return true if not found
VerifyTextOnPage= False
End If
On Error GoTo 0
End Function

Tuesday, November 24, 2009

Get Mouse Over Color of a Link

Using ReplayType setting to Mouse Events while firing an onMouseOver event on the link.

You will see that the hover event is triggered with the ReplayType set to Mouse Events:

Setting.WebPackage("ReplayType") = 2
Browser("xyz").page("xyz").Link("xyz").FireEvent "onMouseOver"
MsgBox Browser("xyz").page("xyz").Link("xyz").Object.currentStyle.color
Setting.WebPackage("ReplayType") = 1


Or

Function GetoverColor(oLink)
Setting.WebPackage("ReplayType") = 2
oLink.FireEvent "onMouseOver"
GetoverColor = oLink.Object.currentStyle.color
Setting.WebPackage("ReplayType") = 1
End Function

Wednesday, December 17, 2008

How to capture error screen-shot in Result Viewer

How to capture error screen-shot in Result Viewer

Dim path_error_file
path_error_file = "C:\Documents and Settings\Desktop\error.bmp"
Browser("Browser").CaptureBitmap path_error_file,True

Reporter.ReportEvent micFail, Object_snap,
"&"

How to capture a tool tip text of a link in QTP?

How to capture a tool tip text of a link in QTP?

This QTP tutorial shows and explains How to get tool tip in QuickTest Professional.

Actually, this is not a difficult task. The steps are:
1.Place mouse cursor over the link
2.Wait for tool tip
3.Get text of shown tool tip
This QTP script captures a text of a tool tip:
' Place mouse cursor over the link

Browser("Yahoo!").Page("Yahoo!").WebElement("text:=My Yahoo!").FireEvent "onmouseover"
wait 1
' Grab tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")