back to nexaweb
search
Close source view

  1. ' get the menu bar object
  2. Set menuBarObj = Browser("Welcome To Nexaweb").Page("Welcome To Nexaweb").JavaApplet("DefaultJvmDetector").JavaObject("MenuBar").Object.getScriptObject()
  3.  
  4. ' check the text of the first menu in the menu bar
  5. Set menu = menuBarObj.getChildElementAt( 0 )
  6. menuText = menu.getText()
  7. if( menuText <>"Menu 1" ) then
  8.     Reporter.ReportEvent micFail,"Menu 0",  "Expected text 'Menu 1'.  Actual text was " + menuText
  9. Else
  10.     Reporter.ReportEvent micPass,"Menu 0",  "Got expected text " + menuText
  11. End If
  12.  
  13. ' check the text of the second menu in the menu bar
  14. Set menu = menuBarObj.getChildElementAt( 2 )
  15. menuText = menu.getText()
  16. if( menuText <>"Menu 2" ) then
  17.     Reporter.ReportEvent micFail,"Menu 0",  "Expected text 'Menu 1'.  Actual text was " + menuText
  18. Else
  19.     Reporter.ReportEvent micPass,"Menu 0",  "Got expected text " + menuText
  20. End If
  21.  
  22. ' check the text of the third menu in the menu bar
  23. Set menu = menuBarObj.getChildElementAt( 4 )
  24. menuText = menu.getText()
  25. if( menuText <>"Menu 3" ) then
  26.     Reporter.ReportEvent micFail,"Menu 0",  "Expected text 'Menu 1'.  Actual text was " + menuText
  27. Else
  28.     Reporter.ReportEvent micPass,"Menu 0",  "Got expected text " + menuText
  29. End If
  30.  
  31. 'Compare XML UI elements to runtime menu items
  32.  
  33. ' get the first menu
  34. Set menuObj = menuBarObj.getMenuBarItemAt( 0 )
  35.  
  36. ' get the menu item elements
  37. Set menuItemElements = menuObj.getChildElements()
  38. menuItemCount = menuItemElements.size()
  39.  
  40. ' select the menu
  41. Set popupMenu = menuObj.select()
  42.  
  43. ' get the count of items in the first popup
  44. popupItemCount = popupMenu.getMenuItemCount()
  45.  
  46. ' compare the popup menu item count to the count for the XML UI
  47. if( menuItemCount <>popupItemCount ) then
  48.     failString = "Expected menu item count of " + CStr( menuItemCount ) + "    Acutal count  was " + CStr( popupItemCount )
  49.     Reporter.ReportEvent micFail,"Menu Item Count",  failString
  50. Else
  51.     Reporter.ReportEvent micPass,"Menu Item Count",  "Got expected count " + CStr( menuItemCount )
  52. End If
  53.  
  54. ' for each item that is not a separator compare the text of the popup menu item to the XML UI menu item
  55. For i = 0 to menuItemCount - 1
  56.     ' get the popup menu item
  57.     Set popupMenuItemObj = popupMenu.getMenuItemAt( i )
  58.     ' get the xml ui menu item
  59.     Set menuItemObj = menuItemElements.elementAt( i )
  60.  
  61.     ' only check the text if the menu item is not a separator
  62.     isSeparator = menuItemObj.isSeparator()
  63.     if( Not isSeparator ) then
  64.         popupItemText = popupMenuItemObj.getText()
  65.         menuItemText = menuItemObj.getText()
  66.         if( menuItemText <> popupItemText ) Then
  67.             failString = "Expected menu item text " + menuItemText + "    Acutal text  was " + popuItemText
  68.             Reporter.ReportEvent micFail,"Menu Item Text",  failString
  69.         Else
  70.             Reporter.ReportEvent micPass,"Menu Item Text",  "Got expected text " + menuItemText
  71.         End If
  72.     End  If
  73. Next
  74.  

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