$show=home$hide=mobile-page

UFT Function to Select an item from a WebList or WinComboBox

UFT/QTP Function to select an item form WebList or WinComboBox. It selects a list item specified in the function call, reports pass or fail.

UFT/QTP Function to select an item form WebList or WinComboBox. It selects a list item specified in the function call, reports pass or fail
UFT/QTP Function to select an item form WebList or WinComboBox. This function is capable of selecting a list item specified in the function call and report pass or fail based on the result. To create and test this function, we have made use of the sample WebList given below and WinComboBox from HP QTP Flight Application.
Sample WebList
Select a destination:
Function Overview
Function Name SelectItemFromList (ByVal TestObject, ByVal ListItem)
Function Description Function to Select an item from a WebList or WinComboBox
Data Parameters TestObject:- Specify the WebList or WinComboBox.
ListItem:- Specify the list item to be selected from the WebList.
[post_ads]

The Function

'--------------------------------------------------------------------------------------------------------------------------------------------
'Function Name        : SelectItemFromList (ByVal TestObject, ByVal ListItem)
'Function Description : Function to Select an item from a WebList or WinComboBox
'Data Parameters      : TestObject:- Specify the WebList or WinComboBox. eg for WebList: Browser("-----").Page("-----").WebList("-----")
'                       eg for WinComboBox:  Window("-----").WinComboBox("-----")
'                       ListItem:- Specify the list item to be selected from the WebList. eg: "Cruises"
'--------------------------------------------------------------------------------------------------------------------------------------------
Function SelectItemFromList (ByVal TestObject, ByVal ListItem)
 Rem: to handle any unexpected error
 On Error Resume Next
 MatchFound = FALSE
 SelectItemFromList = FALSE
 ValidObject = FALSE
 Rem: checking whether the TestObject in the AUT
 ObjectExist = TestObject.Exist(10)
 If ObjectExist Then
  Rem: finding the TestObject class
  Select Case TestObject.GetROProperty("micclass")
   Case "WebList"
    Rem: getting the number of items present in the TestObject
    ListItemsCount = TestObject.GetROProperty("items count")
    ListStart = 1
    ListEnd = ListItemsCount
    ValidObject = TRUE
   Case "WinComboBox"
    Rem: getting the number of items present in the TestObject
    ListItemsCount = TestObject.GetROProperty("items count")
    ListStart = 0
    ListEnd = ListItemsCount - 1
    ValidObject = TRUE
   Case Else
    Rem: reporting error in case the TestObject specified in function call is not WebList or WinComboBox
    Reporter.ReportEvent micFail, "Object Error", "Object '" & TestObject.ToString & "' specified in function call is not a WebList or WinComboBox."
  End Select
  If ValidObject Then
   For iList = ListStart to ListEnd
    CurrentListItem = TestObject.GetItem(iList)
    If StrComp(Trim(CurrentListItem), Trim(ListItem), vbTextCompare) = 0 Then
     MatchFound = TRUE
     TestObject.Select CurrentListItem
     Item_Selected = TestObject.CheckProperty("selection", CurrentListItem, 1000)
     Exit For
    End If
   Next                
   If MatchFound And Item_Selected Then
    SelectItemFromList = TRUE
    Reporter.ReportEvent micPass, "Specified List item selected.", "Specified item '" & ListItem & "' was selected from '" & TestObject.ToString & "'."
   ElseIf Not MatchFound Then
    Reporter.ReportEvent micFail, "List item selection failed.", "Specified item '" & ListItem & "' was not selected from '" & TestObject.ToString & "'."
   End If
  End If
 ElseIf Not ObjectExist Then
  Rem: reporting error if TestObject is not found in AUT
  Reporter.ReportEvent micFail, "Cannot Find The Object", "Object specified in function call cannot be found."
 End If
End Function

Function Usage

Using Function for Web List

Rem: Using function for WebList

Call SelectItemFromList(WebListTestObject, "-Select-")
Rem: Result:- Specified item '-Select-' was selected from '[ select ] list'.

Call SelectItemFromList(WebListTestObject, "Dublin")
Rem: Result:- Specified item 'Dublin' was selected from '[ select ] list'.

Call SelectItemFromList(WebListTestObject, "Dublins")
Rem: Result:- Specified item 'Dublins' was not selected from '[ select ] list'.

Call SelectItemFromList(InvalidWebListTestObject, "Dublin")
Rem: Result:- Object '[ Aneejian] Web page' specified in function call is not a WebList or WinComboBox.
[post_ads_2]

Using Function for WinComboBox

Rem: Using Function for WinComboBox

Call SelectItemFromList(WinComboBoxTestObject, "Zurich")
Rem: Result:- Specified item 'Zurich' was selected from '[ Fly From: ] list'.

Call SelectItemFromList(WinComboBoxTestObject, "Denver")
Rem: Result:- Specified item 'Denver' was selected from '[ Fly From: ] list'.

Call SelectItemFromList(WinComboBoxTestObject, "Zuricsh")
Rem: Result:- Specified item 'Zuricsh' was not selected from '[ Fly From: ] list'.

Call SelectItemFromList(InvalidWinComboBoxTestObject, "Zurich")
Rem: Result:- Object '[ Button ] button' specified in function call is not a WebList or WinComboBox.

COMMENTS





Name

AngularJS,3,Automation Testing,8,CSharp,5,Disqus,1,Excel,2,HP ALM,5,HTML5,1,ISTQB,2,Java Script,2,Manual Testing,7,Photography,1,Quiz,2,REST API,5,Testing,15,UFT,8,VB,5,VBScript,1,Wordpress,1,
ltr
item
Aneejian: UFT Function to Select an item from a WebList or WinComboBox
UFT Function to Select an item from a WebList or WinComboBox
UFT/QTP Function to select an item form WebList or WinComboBox. It selects a list item specified in the function call, reports pass or fail.
https://1.bp.blogspot.com/-2T1xyP1JGJ8/WMky1RXJqrI/AAAAAAAAAGo/QUzxalD0Vho4bo_HU0sCBf7gaxwmi5sHwCLcB/s320/weblist.jpg
https://1.bp.blogspot.com/-2T1xyP1JGJ8/WMky1RXJqrI/AAAAAAAAAGo/QUzxalD0Vho4bo_HU0sCBf7gaxwmi5sHwCLcB/s72-c/weblist.jpg
Aneejian
http://www.aneejian.com/2013/11/uft-function-select-an-item-from-a-weblist-or-wincombobox.html
http://www.aneejian.com/
http://www.aneejian.com/
http://www.aneejian.com/2013/11/uft-function-select-an-item-from-a-weblist-or-wincombobox.html
true
5798203121010168414
UTF-8
Loaded All Posts No posts found VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU ARCHIVE SEARCH ALL POSTS No post found which matches with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy