The two functions below illustrate how you can enhance the QuickTest Test Object Model by either replacing existing test object methods with new ones or by adding new methods to existing test objects.
Function SelectRegExp(Obj, patrn, Button, Offset)
dim NumOfItems, i, CurrentValue, regEx, ItemToSelect, oldFilter
' Initialize the regular expression object with the pattern
oldFilter = Reporter.Filter ' save the default setting
Reporter.Filter = 2 ' Send only errors
' Retrieve the number of items in the list
NumOfItems = obj.GetROProperty("items count")
If regEx.Test(CurrentValue) Then
SelectRegExp = -1 ' item not unique
Reporter.Filter = oldFilter ' Restore the default setting
SelectRegExp = obj.Select(ItemToSelect, Button, Offset)
Function SelectItems(Obj, items)
If (StrComp(obj.GetROProperty("type"), "select-multiple", 1) = 0) Then
' Override the Select function of the WinList object
RegisterUserFunc "WinList", "Select", "SelectRegExp"
' Or add the SelectRegExp function to the WinList object
RegisterUserFunc "WinList", "SelectRegExp", "SelectRegExp"
RegisterUserFunc "WinList", "SelectItems", "SelectItems"
WinList("mylist").Select "2002.*"
WinList("mylist").SelectItems Array("item1", "item3", "item6")
No comments:
Post a Comment