public static void runTaskElement(Element element) throws Exception {
    PoshiRunnerStackTraceUtil.setCurrentElement(element);

    XMLLoggerHandler.updateStatus(element, "pending");

    try {
      SummaryLoggerHandler.startSummary(element);

      parseElement(element);
    } catch (Exception e) {
      SummaryLoggerHandler.failSummary(element, e.getMessage());

      throw e;
    }

    SummaryLoggerHandler.passSummary(element);

    XMLLoggerHandler.updateStatus(element, "pass");
  }
  public static void runMacroExecuteElement(Element executeElement, String macroType)
      throws Exception {

    PoshiRunnerStackTraceUtil.setCurrentElement(executeElement);

    XMLLoggerHandler.updateStatus(executeElement, "pending");

    String classCommandName = executeElement.attributeValue(macroType);

    String className = PoshiRunnerGetterUtil.getClassNameFromClassCommandName(classCommandName);

    PoshiRunnerStackTraceUtil.pushStackTrace(executeElement);

    Element rootElement = PoshiRunnerContext.getMacroRootElement(className);

    List<Element> rootVarElements = rootElement.elements("var");

    for (Element rootVarElement : rootVarElements) {
      runVarElement(rootVarElement, false, true);
    }

    PoshiRunnerStackTraceUtil.popStackTrace();

    List<Element> executeVarElements = executeElement.elements("var");

    for (Element executeVarElement : executeVarElements) {
      runVarElement(executeVarElement, false, false);
    }

    PoshiRunnerStackTraceUtil.pushStackTrace(executeElement);

    SummaryLoggerHandler.startSummary(executeElement);

    Element commandElement = PoshiRunnerContext.getMacroCommandElement(classCommandName);

    try {
      Map<String, String> macroReturns = runMacroCommandElement(classCommandName, commandElement);

      List<Element> returnElements = executeElement.elements("return");

      for (Element returnElement : returnElements) {
        String returnFrom = returnElement.attributeValue("from");

        String returnValue = macroReturns.get(returnFrom);

        if (returnValue != null) {
          String returnName = returnElement.attributeValue("name");

          PoshiRunnerVariablesUtil.putIntoCommandMap(returnName, returnValue);
        }
      }
    } catch (Exception e) {
      SummaryLoggerHandler.failSummary(executeElement, e.getMessage());

      throw e;
    }

    SummaryLoggerHandler.passSummary(executeElement);

    PoshiRunnerStackTraceUtil.popStackTrace();

    XMLLoggerHandler.updateStatus(executeElement, "pass");
  }
  public static void runFunctionExecuteElement(Element executeElement) throws Exception {

    if (_functionExecuteElement == null) {
      _functionExecuteElement = executeElement;
    }

    PoshiRunnerStackTraceUtil.setCurrentElement(executeElement);

    List<Element> executeVarElements = executeElement.elements("var");

    for (Element executeVarElement : executeVarElements) {
      runVarElement(executeVarElement, false, false);
    }

    PoshiRunnerStackTraceUtil.setCurrentElement(executeElement);

    String classCommandName = executeElement.attributeValue("function");

    String className = classCommandName;

    if (classCommandName.contains("#")) {
      className = PoshiRunnerGetterUtil.getClassNameFromClassCommandName(classCommandName);
    }

    Exception exception = null;

    int locatorCount = PoshiRunnerContext.getFunctionLocatorCount(className);

    for (int i = 0; i < locatorCount; i++) {
      String locator = executeElement.attributeValue("locator" + (i + 1));

      if (locator == null) {
        locator = PoshiRunnerVariablesUtil.getValueFromCommandMap("locator" + (i + 1));
      }

      if (locator != null) {
        Matcher matcher = _locatorKeyPattern.matcher(locator);

        if (matcher.find() && !locator.contains("/")) {
          String pathClassName = PoshiRunnerGetterUtil.getClassNameFromClassCommandName(locator);

          String locatorKey =
              PoshiRunnerVariablesUtil.replaceCommandVars(
                  PoshiRunnerGetterUtil.getCommandNameFromClassCommandName(locator));

          PoshiRunnerVariablesUtil.putIntoExecuteMap("locator-key" + (i + 1), locatorKey);

          try {
            locator = PoshiRunnerContext.getPathLocator(pathClassName + "#" + locatorKey);
          } catch (Exception e) {
            exception = e;
          }

          locator = PoshiRunnerVariablesUtil.replaceExecuteVars(locator);
        }

        PoshiRunnerVariablesUtil.putIntoExecuteMap("locator" + (i + 1), locator);
      }

      String value = executeElement.attributeValue("value" + (i + 1));

      if (value == null) {
        value = PoshiRunnerVariablesUtil.getValueFromCommandMap("value" + (i + 1));
      }

      if (value != null) {
        PoshiRunnerVariablesUtil.putIntoExecuteMap("value" + (i + 1), value);
      }
    }

    SummaryLoggerHandler.startSummary(executeElement);

    CommandLoggerHandler.startCommand(executeElement);

    PoshiRunnerStackTraceUtil.pushStackTrace(executeElement);

    Element commandElement = PoshiRunnerContext.getFunctionCommandElement(classCommandName);

    try {
      if (exception != null) {
        throw exception;
      }

      runFunctionCommandElement(classCommandName, commandElement);
    } catch (Throwable t) {
      String warningMessage = _getWarningFromThrowable(t);

      if (warningMessage != null) {
        _functionWarningMessage = warningMessage;
      } else {
        PoshiRunnerStackTraceUtil.popStackTrace();

        if (_functionExecuteElement == executeElement) {
          PoshiRunnerStackTraceUtil.setCurrentElement(executeElement);

          SummaryLoggerHandler.failSummary(_functionExecuteElement, t.getMessage());

          CommandLoggerHandler.failCommand(_functionExecuteElement);

          _functionExecuteElement = null;
          _functionWarningMessage = null;
        }

        throw t;
      }
    }

    PoshiRunnerStackTraceUtil.popStackTrace();

    PoshiRunnerStackTraceUtil.setCurrentElement(executeElement);

    if (_functionExecuteElement == executeElement) {
      if (_functionWarningMessage != null) {
        SummaryLoggerHandler.warnSummary(_functionExecuteElement, _functionWarningMessage);

        CommandLoggerHandler.warnCommand(_functionExecuteElement);
      } else {
        SummaryLoggerHandler.passSummary(executeElement);

        CommandLoggerHandler.passCommand(executeElement);
      }

      _functionExecuteElement = null;
      _functionWarningMessage = null;
    }
  }