-->Other Pre-defined Methods cont...

Select: This method is used to select an item from a list or a combo box or menu or a group of objects (like radio buttons group or a tree view, etc).
We can use Select method either by providing the index or value of the item itself.

Eg: VbWindow(“Material”).VbComboBox(“Mtype”).Select “Chemical”.Select 0
Eg: VbWindow(“Material”).VbMenu(“Menu”).Select “File;New”. VbRadioButtonGroup(“Class”).Select “A”

GetItemsCount: This method is used to get the total number of items from a list or a combo box or menu or radio button group or tree view, etc.
Note: This method can be used for all technologies except Web application.

Eg: ItemsCnt=VbWindow(“Material”).VbComboBox(“Mtype”).GetItemsCount
For i=0 to ItemsCnt-1
VbWindow(“Material”).VbComboBox(“Mtype”).Select i
Next

Eg: Write a script to check a particular item exists in a list or combo box
ExpItem = “Test”
ItemsCnt = Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetROProperty(“ItemsCount”)
For i=0 to ItemsCnt-1
Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).Select i
ActItem = Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetROProperty(“Value”)
msgbox ActItem
If ExpItem = ActItem then
msgbox = “Item found at index” & i
Exit For
End If
Next

Note: A Web list box doesn’t support the method “GetItemsCount”. But it supports the property “ItemsCount”

GetItem: This method is used to get an item value from a list or a combo box by providing the index number.

Eg: ActItem=Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetItem(2)
Msgbox ActItem
ExpItem = “Test”
ItemsCnt = Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetROProperty(“ItemsCount”)
For i=1 to ItemsCnt
ActItem=Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetItem(i)
msgbox ActItem
If ExpItem = ActItem then
Msgbox “Item found at index” & i
Exit for
End If
Next

Eg: Script to select an Item randomly from a list or a combo box.
ItemsCnt = Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetROProperty(“ItemsCount”)
ItemSel = RandomNumber(0,ItemCnt-1)
mgbox ItemSel
Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).Select ItemSel
Msgbox Browser(“OpenEnquiry”).Page(“OpenEnquiry_thread”).WebList(“List Topics”).GetROProperty(“Value”)

Note: ‘ or rem are used to comment a single line code
Cntrl+M is used to comment multiple lines code
Ctrl+Shft+M is used to uncomment multiple lines code