Exemplo n.º 1
0
  protected Object getPropertyObject(String propertyName) throws SAFSException {
    String rval = null;

    if (compObject == null) {
      int status = waitForObject(mapname, windowName, compName, secsWaitForComponent);
      if (status == 0) compObject = ((STestRecordHelper) testRecordData).getCompTestObject();
    }

    if (compObject != null) {
      Log.debug("assignPropVar for " + compObject.getLocator() + ":" + propertyName);
      rval = sUtils.getAttribute(selenium, compObject.getLocator(), propertyName);
      if (rval == null) {
        rval =
            selenium.getEval(
                "var xpath = \""
                    + compObject.getLocator()
                    + "\";var prop = \""
                    + propertyName
                    + "\";SAFSgetAttribute(xpath,prop);");
      }
    } else {
      Log.warn("component object is null.");
    }

    return rval;
  }
Exemplo n.º 2
0
  /**
   * <br>
   * <em>Purpose:</em> verifyProperty
   */
  protected void verifyProperty() throws SAFSException {
    testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
    if (params.size() < 2) {
      paramsFailedMsg(windowName, compName);
      return;
    }
    String prop = (String) iterator.next();
    String val = (String) iterator.next();
    String strcase = "";
    boolean ignorecase = false;
    try {
      strcase = (String) iterator.next();
    } catch (Exception x) {;
    }
    ignorecase = !StringUtils.isCaseSensitive(strcase);

    Log.info(".....CFComponent.process; ready to do the VP for prop : " + prop + " val: " + val);
    String rval = null;

    int status = sUtils.waitForObject(mapname, windowName, compName, 15);

    SGuiObject comp = null;
    String _type = null;

    if (status == 0) {
      comp = ((STestRecordHelper) testRecordData).getCompTestObject();
      _type = ((STestRecordHelper) testRecordData).getCompType();
      // TODO: Changed this!

      // rval = selenium.getEval("var xpath = \""+comp.getLocator()+"\";var prop =
      // \""+prop+"\";SAFSgetAttribute(xpath,prop);");
      rval = sUtils.getAttribute(selenium, comp.getLocator(), prop);
      if (rval == null) {
        Log.info(
            "Selenium property '"
                + prop
                + "' for component '"
                + compName
                + "' of type '"
                + _type
                + "' not found.  Trying alternatives...");
        // assume attribute not found
        if (((_type.equalsIgnoreCase("CHECKBOX")) || (_type.equalsIgnoreCase("RADIOBUTTON")))
            && (prop.equalsIgnoreCase("CHECKED"))
            && (val.equalsIgnoreCase("FALSE"))) {
          rval = "False";
        }
        if (((_type.equalsIgnoreCase("LISTBOX")) || (_type.equalsIgnoreCase("COMBOBOX")))
            && (prop.equalsIgnoreCase("SELECTED"))
            && (val.equalsIgnoreCase("FALSE"))) {
          rval = "False";
        }
      }
    }

    Log.info(
        "Selenium property '"
            + prop
            + "' for component '"
            + compName
            + "' of type '"
            + _type
            + "' contains value '"
            + rval
            + "'");

    // it is possible the property name is not valid for Selenium
    // it may be a property valid in a different engine
    // TODO: but do we want to assume we are running with other engines?
    if (rval == null || rval.equals("null")) {
      testRecordData.setStatusCode(StatusCodes.SCRIPT_NOT_EXECUTED);
      return;
    }

    if (((!ignorecase) && (val.equals(rval))) || (ignorecase && (val.equalsIgnoreCase(rval)))) {
      // set status to ok
      testRecordData.setStatusCode(StatusCodes.NO_SCRIPT_FAILURE);
      altText =
          genericText.convert(
              "bench_matches",
              compName + ":" + prop + " matches expected value \"" + val + "\"",
              compName + ":" + prop,
              val);
      log.logMessage(testRecordData.getFac(), altText, PASSED_MESSAGE);
    } else {
      // failed
      testRecordData.setStatusCode(StatusCodes.GENERAL_SCRIPT_FAILURE);
      altText =
          genericText.convert(
              "bench_not_match",
              compName + ":" + prop + " did not match expected result \"" + val + "\"",
              compName + ":" + prop,
              val);
      String detail = genericText.convert("actual_value", "ActualValue='" + rval + "'", rval);
      standardFailureMessage(altText, compName + ":" + prop + " " + detail);
    }
  }