Esempio n. 1
0
  /**
   * <br>
   * <em>Purpose:</em> process: process the testRecordData <br>
   * This is our specific version. We subclass the generic CFComponent. The types of objects handled
   * here are '{@link GuiSubitemTestObject}' and '{@link ToggleGUITestObject}'. Path Example:
   * "Admin->Customers..." The actions handled here are: <br>
   *
   * <ul>
   *   <li>selectmenuitem
   *   <li>selectmenuitemcontains
   *   <li>verifymenuitem
   *   <li>verifymenuitemcontains
   * </ul>
   *
   * <br>
   * <br>
   * <em>Side Effects:</em> {@link #testRecordData} statusCode is set based on the result of the
   * processing <br>
   * <em>State Read:</em> {@link #testRecordData}, {@link #params} <br>
   * <em>Assumptions:</em> none
   */
  protected void localProcess() {
    try {
      // then we have to process for specific items not covered by our super
      log.logMessage(
          testRecordData.getFac(),
          getClass().getName() + ".process, searching specific tests...",
          DEBUG_MESSAGE);

      if (action != null) {
        Log.info(
            ".....CFMenuBar.process; ACTION: "
                + action
                + "; win: "
                + windowName
                + "; comp: "
                + compName);
        if ((action.equalsIgnoreCase(SELECTMENUITEM))
            || (action.equalsIgnoreCase(SELECTPOPUPMENUITEM))) {
          selectMenuItem();
        } else if ((action.equalsIgnoreCase(SELECTMENUITEMCONTAINS))) {
          selectMenuItemContains();
        } else if ((action.equalsIgnoreCase(SELECTUNVERIFIEDMENUITEM))) {
          selectUnverifiedMenuItem();
        } else if (action.equalsIgnoreCase(SELECTUNVERIFIEDPOPUPMENUITEM)) {
          selectUnverifiedPopupMenuItem();
        } else if ((action.equalsIgnoreCase(VERIFYMENUITEM))
            || (action.equalsIgnoreCase(VERIFYPOPUPMENUITEM))) {
          verifyMenuItem();
        } else if ((action.equalsIgnoreCase(VERIFYMENUITEMCONTAINS))
            || (action.equalsIgnoreCase(VERIFYPOPUPMENUCONTAINS))
            || (action.equalsIgnoreCase(VERIFYPOPUPMENUPARTIALMATCH))) {
          verifyMenuItemContains();
        } else if (action.equalsIgnoreCase(VERIFYPOPUPMENU)) {
          verifyPopupMenu();
        }
        // all for now
      }
    } catch (com.rational.test.ft.SubitemNotFoundException snfe) {
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(
          testRecordData.getFac(),
          "SubitemNotFoundException: " + snfe.getMessage(),
          FAILED_MESSAGE);
    } catch (com.rational.test.ft.ObjectNotFoundException onfe) {
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(
          testRecordData.getFac(), "ObjectNotFoundException: " + onfe.getMessage(), FAILED_MESSAGE);
    } catch (SAFSException ex) {
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(testRecordData.getFac(), "SAFSException: " + ex.getMessage(), FAILED_MESSAGE);
    } catch (Exception unk) {
      unk.printStackTrace();
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(
          testRecordData.getFac(),
          unk.getClass().getName() + ": " + unk.getMessage(),
          FAILED_MESSAGE);
    }
  }
Esempio n. 2
0
 /**
  * @param guiObj, TestObject may be JMenuBar or JPopupMenu
  * @param path, String is the full path of some MenuItem on which a click action will take place
  * @param fuzzy, boolean, If true, we will do a non-exact verification of existance of path
  */
 protected void selectMenuItemWithVerification(
     GuiSubitemTestObject guiObj, String path, boolean fuzzy) {
   MenuTree atree = null;
   try {
     atree = (MenuTree) extractMenuItems(guiObj, 0);
     log.logMessage(testRecordData.getFac(), "atree: " + atree, DEBUG_MESSAGE);
     // Do the work of matching..., verify the path
     // If fuzzy is true, do the partial match; otherwise do the exact match
     String match = atree.matchPath(path, fuzzy, null);
     if (match != null) {
       log.logMessage(testRecordData.getFac(), "match: " + match, DEBUG_MESSAGE);
       com.rational.test.ft.script.List slist = Script.localAtPath(match);
       try {
         guiObj.click(slist);
         // set status to ok
         testRecordData.setStatusCode(StatusCodes.OK);
         String altText =
             "MenuItem \"" + match + "\" clicked, " + windowName + ":" + compName + " " + action;
         log.logMessage(
             testRecordData.getFac(),
             passedText.convert(PRE_TXT_SUCCESS_4, altText, match, windowName, compName, action),
             PASSED_MESSAGE);
       } catch (TargetGoneException tge) {
         Log.info(
             "CFMenuBar IGNORING TargetGoneException probably resulting from intended window closure...");
         // set status to ok
         testRecordData.setStatusCode(StatusCodes.OK);
         String altText =
             "MenuItem \"" + match + "\" clicked, " + windowName + ":" + compName + " " + action;
         log.logMessage(
             testRecordData.getFac(),
             passedText.convert(PRE_TXT_SUCCESS_4, altText, match, windowName, compName, action),
             PASSED_MESSAGE);
       } catch (NullPointerException npe) {
         testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
         log.logMessage(testRecordData.getFac(), "item not found: " + path, FAILED_MESSAGE);
       }
     } else {
       testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
       log.logMessage(
           testRecordData.getFac(),
           getClass().getName() + ": no match on: " + path,
           FAILED_MESSAGE);
     }
   } catch (SAFSException se) {
     testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
     log.logMessage(
         testRecordData.getFac(), getClass().getName() + ": " + se.getMessage(), FAILED_MESSAGE);
   }
 }
Esempio n. 3
0
  /** Maximize the current window */
  protected void _maximize() throws SAFSException {
    String message = null;

    // The window can't be resotred if it is maximized by selenium API.
    // So use the SAFS Robot to maximize the windows firstly
    try {
      super._maximize();
      return;
    } catch (SAFSException e) {
      message =
          "Can't maximize window by SAFS Robot. Try Selenium API to maximize. Exception="
              + e.getMessage();
      Log.warn(message);
      if (!sUtils.maximizeWindow(winObject.getWindowId(), selenium)) {
        throw new SAFSException("Fail to maximize by Selenium API.");
      }
    }
  }
Esempio n. 4
0
  /**
   * <br>
   * <em>Purpose:</em> Verify the existance of a path and verify it's status
   *
   * @param anObj -- GuiSubItemTestObject representing a JMenuBar or JPopupMenu.
   * @param menuItemPath -- String, the path to be selected
   * @param status -- String, the menuItem status to be verified
   * @param fuzzy -- If false, match the given path exactly with the Menu.
   * @exception SAFSException
   */
  protected void verifyMenuBar(Object anObj, String menuItemPath, String status, boolean fuzzy)
      throws SAFSException {

    String debugmsg = getClass().getName() + ".verifyMenuBar() ";
    TestObject testObj = (TestObject) anObj;

    GuiSubitemTestObject guiObj = new GuiSubitemTestObject(testObj.getObjectReference());
    log.logMessage(testRecordData.getFac(), "..... guiObj: " + guiObj, DEBUG_MESSAGE);
    log.logMessage(testRecordData.getFac(), "..... path: " + menuItemPath, DEBUG_MESSAGE);
    listNonValueProperties(guiObj);
    listProperties(guiObj);

    MenuTree atree = null;
    try {
      atree = (MenuTree) extractMenuItems(guiObj, 0);
      log.logMessage(testRecordData.getFac(), "atree: " + atree, DEBUG_MESSAGE);
      // do the work of matching...
      String match = null;
      match = atree.matchPath(menuItemPath, fuzzy, status);

      if (match != null) {
        log.logMessage(testRecordData.getFac(), "match: " + match, DEBUG_MESSAGE);
        // set status to ok
        testRecordData.setStatusCode(StatusCodes.OK);
        String altText =
            "MenuItem \"" + match + "\", " + windowName + ":" + compName + " " + action;
        log.logMessage(
            testRecordData.getFac(),
            passedText.convert(PRE_TXT_SUCCESS_4, altText, match, windowName, compName, action),
            PASSED_MESSAGE);
      } else {
        testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
        log.logMessage(
            testRecordData.getFac(), debugmsg + ": no match on: " + menuItemPath, FAILED_MESSAGE);
      }
    } catch (SAFSException se) {
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(testRecordData.getFac(), debugmsg + ": " + se.getMessage(), FAILED_MESSAGE);
    }
  }
Esempio n. 5
0
  public void process() {
    String debugmsg = this.getClass().getName() + ".process(): ";
    // assume this for now..
    sHelper = (STestRecordHelper) testRecordData;
    try {
      selenium = SApplicationMap.getSelenium(sHelper.getWindowName());
    } catch (SAFSException e) {
      selenium = SApplicationMap.getSelenium("");
    }
    testRecordData.setStatusCode(StatusCodes.SCRIPT_NOT_EXECUTED);
    try {
      getHelpers();
      sUtils = (SeleniumGUIUtilities) utils;
    } catch (SAFSException ex) {
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      log.logMessage(
          testRecordData.getFac(),
          "SAFSException: " + ex.getClass().getName() + ", msg: " + ex.getMessage(),
          FAILED_MESSAGE);
      return;
    }

    winObject = sHelper.getWindowTestObject();
    compObject = sHelper.getCompTestObject();
    if (winObject == null) {
      Log.warn(debugmsg + " Window Object is null, try to get it through SeleniumGUIUtility. ");
      try {
        if (sUtils.waitForObject(mapname, windowName, windowName, secsWaitForWindow) == 0) {
          Log.debug(debugmsg + " we got the window object through SeleniumGUIUtility.");
          winObject = ((STestRecordHelper) testRecordData).getWindowTestObject();
        } else {
          Log.debug(
              debugmsg
                  + " can not get window object through SeleniumGUIUtility: waitForObject() error.");
        }
      } catch (SAFSObjectNotFoundException e) {
        Log.debug(
            debugmsg
                + " can not get window object through SeleniumGUIUtility: Exception="
                + e.getMessage());
      }
      if (winObject == null) {
        Log.error(debugmsg + "  Window Object is still null");
        testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
        log.logMessage(
            testRecordData.getFac(),
            action + " failed, due to 'Window Object is null'",
            FAILED_MESSAGE);
        return;
      }
    }

    if (compObject == null) {
      Log.warn(debugmsg + " Component Object is null, try to get it through SeleniumGUIUtility.");
      if (!windowName.equals(compName)) {
        try {
          if (sUtils.waitForObject(mapname, windowName, compName, secsWaitForWindow) == 0) {
            Log.debug(debugmsg + " we get the component object through SeleniumGUIUtility.");
            compObject = ((STestRecordHelper) testRecordData).getCompTestObject();
          } else {
            Log.debug(
                debugmsg
                    + " can not get component object through SeleniumGUIUtility: waitForObject() error.");
          }
        } catch (SAFSObjectNotFoundException e) {
          Log.debug(
              debugmsg
                  + " can not get component object through SeleniumGUIUtility: Exception="
                  + e.getMessage());
        }

        if (compObject == null) {
          Log.warn(debugmsg + "  Component Object is still null.");
        }
      }
    }

    //		updateFromTestRecordData();//why this is commented?

    // do the work
    localProcess();

    if (testRecordData.getStatusCode() == StatusCodes.SCRIPT_NOT_EXECUTED) {
      componentProcess(); // handle Generic keywords
    } else {
      Log.debug(debugmsg + " processed " + testRecordData);
      Log.debug(debugmsg + " params " + params);
    }
  }