back to nexaweb
search
Close source view

  1. ' get the applet script object
  2. Set appObj = Browser("Welcome To Nexaweb").Page("Welcome To Nexaweb").JavaApplet("DefaultJvmDetector").Object.getScriptObject()
  3.  
  4. 'get the combobox script object
  5. Set comboBox = appObj.findObjectById("combobox")
  6.  
  7. ' get the label script object
  8. Set label = appObj.findObjectByid("mylabel")
  9.  
  10. 'test inital state of combo
  11. text = comboBox.getText()
  12. if( text <>"ComboBox") then
  13.    result = "Expected 'ComboBox' Actual was '" + text + "'"
  14.    Reporter.ReportEvent micFail,"ComboBox", result
  15. Else
  16.    Reporter.ReportEvent micDone,"ComboBox", "Intial Text passed. was 'ComboBox'"
  17. End If
  18.  
  19. 'test intiial state of label
  20. text = label.getText()
  21. if( text <>"Label to Change") then
  22.    result = "Expected 'Label to Change' Actual was '" + text + "'"
  23.    Reporter.ReportEvent micFail,"Label", result
  24. Else
  25.    Reporter.ReportEvent micDone,"Label", "Intial Text passed. was 'Label to Change'"
  26. End If
  27.  
  28.  
  29. ' get the count of the items in the combobox
  30. itemCount = comboBox.getItemCount()
  31.  
  32. ' get the vector of the items and the size of the return
  33. Set itemobjs = comboBox.getItems()
  34. sizeItems = itemobjs.size()
  35.  
  36. ' verify the size of the return is correct
  37. if( itemCount <> sizeItems ) then
  38.    result = "Expected " +itemCount + " tiems Actual was '" + sizeItems + "'"
  39.    Reporter.ReportEvent micFail,"Label", result
  40. Else
  41.    Reporter.ReportEvent micDone,"ComboBox", "Number of Items was "+itemCount
  42. End If
  43.  
  44. ' select each item and test the combobox and label text
  45. ' to ensure selection and onStateChange() event has fied correctly
  46. For i = 0 to itemCount - 1
  47.  
  48.    ' select the tiem
  49.    comboBox.selectItemAt( i )
  50.  
  51.    ' check the text of the combobox against the text of the item being selected
  52.    tag = "Selected Item #" + CStr(i) + " - ComboBox"
  53.    expectedText = itemobjs.elementAt(i).getText()
  54.    text = comboBox.getText()
  55.  
  56.    if( text <> expectedText ) then
  57.       result = "Expected '" + expectedText + "' Actual was '" + text + "'"
  58.       Reporter.ReportEvent micFail,tag, result
  59.    Else
  60.       Reporter.ReportEvent micDone, tag, "ComboBox text was '" + expectedText +"'"
  61.       End If
  62.  
  63.    ' check the text of the label against the value of the item being selected
  64.    tag = "Selected Item #" + CStr(i) + " - Label"
  65.    expectedText = itemobjs.elementAt(i).getValue()
  66.    text = label.getText()
  67.  
  68.    if( text <> expectedText) then
  69.       result = "Expected '" + expectedText + "' Actual was '" + text + "'"
  70.       Reporter.ReportEvent micFail,tag, result
  71.    Else
  72.       Reporter.ReportEvent micDone,tag, "Label Text passed. was '" + expectedText +"'"
  73.    End If
  74. Next
  75.  
  76.  
  77.  

© Copyright 2005-2008 Nexaweb Technologies Inc. All Rights Reserved.