selenium 读取xml

try{
File f = new File("TestPlan.xml");
SAXReader reader = new SAXReader();
Document doc = reader.read(f);
Element root = doc.getRootElement();

Element e = null;
e = root.element("TestServer");
hTestServer.serverName = e.elementTextTrim("ServerName");
hTestServer.port = Integer.parseInt(e.elementTextTrim("Port"));
hdefaultTimeOut = e.elementTextTrim("DefaultTimeOut");

for (Iterator i = root.elementIterator("Site"); i.hasNext();){
e = (Element)i.next();
hSiteList.add(new TestSite(e.elementTextTrim("baseURL"), e.elementTextTrim("initPath"), Boolean.parseBoolean(e.elementTextTrim("Enable"))));
}


for (Iterator i = root.elementIterator("TestCase"); i.hasNext();){
e = (Element)i.next();
hTestCaseList.add(new Case(e.elementTextTrim("Name"), Boolean.parseBoolean(e.elementTextTrim("Enable"))));
}
}
catch(Exception e)
{
e.printStackTrace();
}

你可能感兴趣的:(selenium)