[英]How to access the property tag of TEST-result.xml from junit-frames.xsl?
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="0" hostname="xxx19" name="MyProject.TestSuite" tests="2" time="105.112" timestamp="2012-04-30T11:32:18">
<properties>
<property name="java.vendor" value="Oracle Corporation" />
<property name="reportstyle" value="." />
<property name="sun.java.launcher" value="SUN_STANDARD" />
<property name="sun.management.compiler" value="HotSpot Client Compiler" />
<property name="lib" value="C:\Selenium\Selenium JARs" />
<property name="os.name" value="Windows 7" />
<property name="TODAY" value="April 30 2012" />
<property name="report" value="C:\Selenium-Reports\MyProject-April 30 2012 (17_02_15)" />
<property name="sun.desktop" value="windows" />
<property name="java.vm.specification.vendor" value="Oracle Corporation" />
<property name="ant.home" value="C:\apache-ant-1.8.3" />
<property name="java.runtime.version" value="1.7.0-ea-b119" />
<property name="user.name" value="hpadmin" />
<property name="START_TIME" value="17_02_15" />
</properties>
這是我的TEST-results.xml中的片段
如何從junit-frames.xsl文件讀取以下屬性
屬性名稱=“ report” value =“ C:\\ Selenium-Reports \\ MyProject-2012年4月30日(17_02_15)”
請只做那些需要的。
提前致謝,
-哈努曼
最終的DocumentBuilder構建器= DocumentBuilderFactory.newInstance()。newDocumentBuilder();
final Document doc = builder.parse(new File("c://Test.xml"));
final Element root = doc.getDocumentElement();
final NodeList list = root.getElementsByTagName("properties");
for (int i = 0; i < list.getLength(); i++)
{
final NodeList propertyList = list.item(i).getChildNodes();
for (int j = 0; j < propertyList.getLength(); j++)
{
final Node property = propertyList.item(j);
if (property.hasAttributes() && property.getAttributes().item(0).getNodeValue().equals("report"))
{
System.out.println(property.getAttributes().item(1).getNodeValue());
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.