我有以下代码在测试执行后生成html页面,现在我想更改标签的背景颜色和字体颜色。请帮忙怎么做。
从data.js文件中挑选数据,该文件是Json文件。我在哪里以及如何在下面的代码中更改html页面上的颜色?
public class MailComponent {
public static String getHTMLBody() {
try {
JSONObject testData = (JSONObject) Control.ReportManager.pHandler.getData();
File file = new File(FilePath.getMailReportTemplatePath(), "mailBody.html");
String str = FileUtils.readFileToString(file, Charset.defaultCharset());
str = str.replace("{releaseName}", testData.get("releaseName").toString()).
replace("{testSetName}", testData.get("testsetName").toString()).
replace("{parallelThreads}", testData.get("maxThreads").toString()).
replace("{runConfig}", testData.get("runConfiguration").toString()).
replace("{startTime}", testData.get("startTime").toString()).
replace("{endTime}", testData.get("endTime").toString()).
replace("{totalDuration}", testData.get("exeTime").toString()).
replace("{passedTests}", testData.get("nopassTests").toString()).
replace("{failedTests}", testData.get("nofailTests").toString());
StringBuilder html = new StringBuilder();
for (Object tc : (JSONArray) testData.get("EXECUTIONS")) {
JSONObject json = (JSONObject) tc;
html.append("</tr>")
.append("<td>").append(json.get("scenarioName")).append("</td>\n")
.append("<td>").append(json.get("testcaseName")).append("</td>\n")
.append("<td>").append(json.get("browser")).append("</td>\n")
.append("<td>").append(json.get("exeTime")).append("</td>\n")
.append("<td>").append(json.get("status")).append("</td>\n")
.append("<td>").append(json.get("bversion")).append("</td>\n")
.append("<td>").append(json.get("platform")).append("</td>\n")
.append("<td>").append(json.get("iterations")).append("</td>\n")
.append("</tr>");
}
str = str.replace("{reportData}", html.toString());
return str;
} catch (IOException ex) {
Logger.getLogger(MailComponent.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
答案 0 :(得分:0)
将颜色或背景颜色属性及其值附加到String对象
中示例:此td将背景颜色设置为红色
sealed