'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''SCRIPT NAME: Select Random Web List Value ''' '''SCRIPT CREATOR: Automated Testing Institute ''' '''SCRIPT OBJECTIVE: The objective of this script is to randomly select a value ''' from a web list box '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function selectRandomWebListValue(objIEArg) 'Access the List Item 'Note: The Math Test Application has a 'Select Number Sets' list item that has a Name property equal to 'numSets'. ' This numSets object will be used. set numSetsObject = objIEArg.document.all("numSets") 'Get a collection of all list items (options objects) set listItemCollection = numSetsObject.options 'Get a count of the total number of items in the collection listItemCount = listItemCollection.length 'Use random number generator to randomly select a list item index Randomize randomListIndex = Int(listItemCount * Rnd) 'Click the random list item objIEArg.document.all("numSets").selectedIndex = randomListIndex 'Print the Index and the List Item Text to the screen msgbox "The index number of the item selected from the List Object is '" & randomListIndex & "' and the text of this option is: " + listItemCollection.item(randomListIndex).text End Function 'Test the Function 'Declare Variables Dim objIE 'Instantiate an Instance of IE set objIE = CreateObject("InternetExplorer.Application") 'Make the browser visible objIE.visible = "true" 'Navigate to the desired website objIE.navigate "http://www.dijohn-ic.com/MathTestApplication1.html" wscript.sleep 2000 selectRandomWebListValue(objIE)