/**
   * Initializes the {@link ActionResponse} with default information.
   *
   * @param context the test context
   * @param metadata the current metadata object
   * @param actionType the current action
   */
  private void initResult(TestContext context, Metadata metadata, SubEngineActionType actionType) {
    StringBuilder msg = new StringBuilder();
    msg.append("Executing ");
    msg.append(getClass().getSimpleName().replace("Impl", ""));
    msg.append(" with name='");
    msg.append(metadata != null ? metadata.getId() : "null");
    msg.append(" and action='");
    msg.append(actionType);
    msg.append("'");

    this.result = TestResultHelper.createActionResponse();
    this.result.setMessage(msg.toString());
  }
  /** {@inheritDoc} */
  @Override
  protected ActionResponse internalExecute(
      TestContext context, PropertyList propertyList, Metadata metadata, WebActionType actionType) {

    ActionResponse result = TestResultHelper.createActionResponse();
    WebComponentCommand command = null;

    try {
      switch (actionType) {
        case ENTER:
          command = new EnterTextCommand(this.getSelenium());
          break;

        case READ:
          command = new ReadTextFieldCommand(this.getSelenium());
          break;

        case CLEAR:
          command = new ClearTextFieldCommand(this.getSelenium());
          break;

        case PRESS_KEY:
          command = new PressKeyCommand(this.getSelenium());
          break;

        default:
          return failResult(
              metadata,
              actionType,
              "Unsupported WebActionType for WebTextField: '" + actionType + "'");
      }

      // Execute WebCommand
      PropertyList returnProperties = command.execute(metadata, propertyList);

      result.setMessage("Executed WebTextField action='" + actionType + "'");
      result.setReturnProperties(returnProperties);
      result.setActionStatus(ActionStatusType.EXECUTED);
      return result;
    } catch (WebComponentException ex) {
      String errorMessage =
          "Could not execute "
              + actionType
              + " on WebTextField '"
              + metadata.getName().getValue()
              + "'. Cause: "
              + ex.getMessage();
      this.error(errorMessage);
      result.setErrorMessage(errorMessage);
      result.setActionStatus(ActionStatusType.FAILED);
      return result;
    } catch (Exception ex) {
      this.fatal(ex);
      result.setErrorMessage(
          "Could not execute "
              + actionType
              + " on WebTextField '"
              + metadata.getName().getValue()
              + "'. Cause: "
              + ex.toString());
      result.setActionStatus(ActionStatusType.FAILED);
      return result;
    } finally {

      if (context.isTracingEnabled() && command != null) {
        result.setActionTrace(command.getActionTrace());
      }
    }
  }