' get the applet script object
Set appObj = Browser("Welcome To Nexaweb").
Page("Welcome To Nexaweb").JavaApplet("DefaultJvmDetector").
Object.getScriptObject()
'get the combobox script object
Set comboBox = appObj.findObjectById("combobox")
' get the label script object
Set label = appObj.findObjectByid("mylabel")
'test inital state of combo
text = comboBox.getText()
if( text <>"ComboBox") then
result = "Expected 'ComboBox' Actual was '" + text + "'"
Reporter.ReportEvent micFail,"ComboBox", result
Else
Reporter.ReportEvent micDone,"ComboBox",
"Intial Text passed. was 'ComboBox'"
End If
'test intiial state of label
text = label.getText()
if( text <>"Label to Change") then
result = "Expected 'Label to Change' Actual was '" + text + "'"
Reporter.ReportEvent micFail,"Label", result
Else
Reporter.ReportEvent micDone,"Label",
"Intial Text passed. was 'Label to Change'"
End If
' get the count of the items in the combobox
itemCount = comboBox.getItemCount()
' get the vector of the items and the size of the return
Set itemobjs = comboBox.getItems()
sizeItems = itemobjs.size()
' verify the size of the return is correct
if( itemCount <> sizeItems ) then
result = "Expected " +itemCount +
" tiems Actual was '" + sizeItems + "'"
Reporter.ReportEvent micFail,"Label", result
Else
Reporter.ReportEvent micDone,"ComboBox",
"Number of Items was "+itemCount
End If
' select each item and test the combobox and label text
' to ensure selection and onStateChange() event has fied correctly
For i = 0 to itemCount - 1
' select the tiem
comboBox.selectItemAt( i )
' check the text of the combobox against the
' text of the item being selected
tag = "Selected Item #" + CStr(i) + " - ComboBox"
expectedText = itemobjs.elementAt(i).getText()
text = comboBox.getText()
if( text <> expectedText ) then
result = "Expected '" + expectedText +
"' Actual was '" + text +
"'"Reporter.ReportEvent micFail,tag, result
Else
Reporter.ReportEvent micDone, tag,
"ComboBox text was '" + expectedText +"'"
End If
' check the text of the label against the value of
' the item being selected
tag = "Selected Item #" + CStr(i) + " - Label"
expectedText = itemobjs.elementAt(i).getValue()
text = label.getText()
if( text <> expectedText) then
result = "Expected '" + expectedText + "' Actual was '" +
text + "'" Reporter.ReportEvent micFail,tag, result
Else
Reporter.ReportEvent micDone,tag,
"Label Text passed. was '" + expectedText +"'"
End If
Next |