Check for a dialog window

Check for an information window set by MENU with STYLE="dialog".

In this task you test if the application has opened a dialog window from a MENU with STYLE="dialog". Using the BDL function CurrentDialogSelector(), you retrieve the current dialog from the AUI tree. Using the XML document with the part of the AUI tree containing the dialog, you look for the node name "Menu", and check if the STYLE attribute has the value dialog.
Note:

The Java API provides a method to retrieve the current dialog.

  1. In your test scenario module import the xml class.
    IMPORT xml
  2. Add a helper function to your test module to handle the failure notification for the test.
    PUBLIC FUNCTION myError(message STRING) 
      CALL ggc.notifyFailure(message)
      CALL ggc.end()
      EXIT PROGRAM 1
    END FUNCTION
    Where:
    • The call to the notifyFailure() function in the ggc API, notifies the test result with details in the error message.
    • The call to the end() function, notifies the BDL scenario server that the scenario execution ends.
  3. In your test scenario play function, code to retrieve the current dialog.
    DEFINE doc xml.DomDocument
    DEFINE root xml.DomNode
    DEFINE style STRING
    
    LET doc = ggc.getAuiTreePart(ggc.CurrentDialogSelector())
    LET root = doc.getDocumentElement()
    Where:
    • doc is defined as a DomDocument object.
    • root is defined as a DomNode object.
    • ggc.CurrentDialogSelector() is passed as a parameter to the getAuiTreePart() function called to retrieve the part of the AUI tree with the current dialog.
  4. Check if the root node name is "Menu", and if the STYLE attribute exists and has the value "dialog".

    For example, code the following; calling the helper function (myError() to handle the errors encountered.

    IF root IS NULL THEN 
      CALL myError("Failed to retrieve current dialog.")
    END IF
    IF root.getNodeName() != "Menu" THEN
      CALL myError( SFMT("Unexpected dialog type, expected Menu, got %1.", root.getNodeName()))
    END IF
    LET style = root.getAttribute("style")
    IF style IS NULL THEN
      CALL myError("Failed to retrieve style attribute on current dialog.")
    END IF
    IF style != "dialog" THEN
      CALL myError( SFMT("Unexpected style attribute on current dialog, expected 'dialog', got %1.", style))
    END IF