' get the menu bar object
Set menuBarObj = Browser("Welcome To Nexaweb").Page("Welcome To Nexaweb").JavaApplet("DefaultJvmDetector").JavaObject("MenuBar").Object.getScriptObject()
' check the text of the first menu in the menu bar
Set menu = menuBarObj.getChildElementAt( 0 )
menuText = menu.getText()
if( menuText <>"Menu 1" ) then
Reporter.ReportEvent micFail,"Menu 0", "Expected text 'Menu 1'. Actual text was " + menuText
Else
Reporter.ReportEvent micPass,"Menu 0", "Got expected text " + menuText
End If
' check the text of the second menu in the menu bar
Set menu = menuBarObj.getChildElementAt( 2 )
menuText = menu.getText()
if( menuText <>"Menu 2" ) then
Reporter.ReportEvent micFail,"Menu 0", "Expected text 'Menu 1'. Actual text was " + menuText
Else
Reporter.ReportEvent micPass,"Menu 0", "Got expected text " + menuText
End If
' check the text of the third menu in the menu bar
Set menu = menuBarObj.getChildElementAt( 4 )
menuText = menu.getText()
if( menuText <>"Menu 3" ) then
Reporter.ReportEvent micFail,"Menu 0", "Expected text 'Menu 1'. Actual text was " + menuText
Else
Reporter.ReportEvent micPass,"Menu 0", "Got expected text " + menuText
End If
'Compare XML UI elements to runtime menu items
' get the first menu
Set menuObj = menuBarObj.getMenuBarItemAt( 0 )
' get the menu item elements
Set menuItemElements = menuObj.getChildElements()
menuItemCount = menuItemElements.size()
' select the menu
Set popupMenu = menuObj.select()
' get the count of items in the first popup
popupItemCount = popupMenu.getMenuItemCount()
' compare the popup menu item count to the count for the XML UI
if( menuItemCount <>popupItemCount ) then
failString = "Expected menu item count of " + CStr( menuItemCount ) + " Acutal count was " + CStr( popupItemCount )
Reporter.ReportEvent micFail,"Menu Item Count", failString
Else
Reporter.ReportEvent micPass,"Menu Item Count", "Got expected count " + CStr( menuItemCount )
End If
' for each item that is not a separator compare the text of the popup menu item to the XML UI menu item
For i = 0 to menuItemCount - 1
' get the popup menu item
Set popupMenuItemObj = popupMenu.getMenuItemAt( i )
' get the xml ui menu item
Set menuItemObj = menuItemElements.elementAt( i )
' only check the text if the menu item is not a separator
isSeparator = menuItemObj.isSeparator()
if( Not isSeparator ) then
popupItemText = popupMenuItemObj.getText()
menuItemText = menuItemObj.getText()
if( menuItemText <> popupItemText ) Then
failString = "Expected menu item text " + menuItemText + " Acutal text was " + popuItemText
Reporter.ReportEvent micFail,"Menu Item Text", failString
Else
Reporter.ReportEvent micPass,"Menu Item Text", "Got expected text " + menuItemText
End If
End If
Next