public void addElementResult(Element element, TestResult result, List<Step> steps) throws IOException {
element.setAttribute("end", DATE_FORMAT.format(new Date()));
element.setAttribute("result", result.name());
for (int i = 0; i < steps.size(); i++) {
Element stepElement = new Element("step");
Step step = steps.get(i);
if (step.getAction() != null) {
Element actionElement = new Element("action");
actionElement.setText(step.getAction());
stepElement.addContent(actionElement);
}
if (step.getResult() != null) {
for (int j = 0; j < step.getResult().size(); j++) {
Element actionElement = new Element("result");
actionElement.setText(step.getResult().get(j).toString());
stepElement.addContent(actionElement);
}
}
if (step.getErrorResult() != null) {
for (int j = 0; j < step.getErrorResult().size(); j++) {
Element actionElement = new Element("error");
actionElement.setText(step.getErrorResult().get(j).toString());
stepElement.addContent(actionElement);
}
}
if (step.getScreenShot() != null) {
Element scrElement = new Element("screen-shot");
scrElement.setText(step.getScreenShot().getPath());
scrElement.setAttribute("title", step.getScreenShot().getTitle());
stepElement.addContent(scrElement);
}
element.addContent(stepElement);
}
writeSuiteFile();