@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("SwingComponent "); builder.append(type); builder.append(":\n - Communication = "); builder.append(communication == null || !communication.isActive() ? "Deactive" : "Active"); builder.append("\n - Result = "); builder.append( result == null || result.getActionStatus() == null ? "NOT FINISHED" : result.getActionStatus()); return builder.toString(); }
@Override public ActionResponse execute( TestContext context, PropertyList propertyList, List<Metadata> metadataList, SubEngineActionType actionType) throws SubEngineException { Metadata metadata = null; try { // Validation this.validateArguments(context, propertyList, metadataList, actionType); SwingActionType swingAction = (SwingActionType) actionType; // Init result metadata = metadataList.get(metadataList.size() - 1); this.initResult(context, metadata, actionType); // this.validateComponent(propertyList, swingAction); // Execute Command ExecutionCommand command = createCommand(propertyList, metadata, swingAction); Integer timeout = getTimeout(metadata, swingAction); Property reply = executeCommand(context, command, timeout); if (reply != null) { PropertyList returnList = PropertyHelper.createPropertyList("Return"); PropertyHelper.add(reply, returnList); result.setReturnProperties(returnList); } } catch (SwingValidationException e) { logger.error(e, "Error validating Swing component."); failResult(metadata, actionType, e.getMessage()); } catch (Exception e) { logger.error(e, "Error during Swing component execution."); failResult(metadata, actionType); } return result; }
/** {@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()); } } }