Thinking about adding some functionality to the frame.
The first thing to think about is generating a test report
This is about what format the file is generated in.
I'll be right here. Generate XML-formatted files
I first learned the following code:
1 #!/usr/bin/env python2 #-*-coding:utf_8-*-3 4 fromXml.domImportMinidom5 6XML =Minidom. Document ()7Xml.appendchild (Xml.createcomment ("Test Report"))8Caselist = Xml.createelement ("caselist")9 xml.appendchild (caselist)Ten One A defAdd_xml (newxml): -Case = Xml.createelement (" Case") -Case.setattribute ("ID", newxml["ID"]) the - -Name = Xml.createelement ("name") -Name.appendchild (Xml.createtextnode (newxml["name"])) +Code = xml.createelement ("Code") -Code.appendchild ((Xml.createtextnode (newxml["Code"]))) +result = Xml.createelement ("result") AResult.appendchild (Xml.createtextnode (newxml["result"])) atTime = Xml.createelement (" Time") -Time.appendchild (Xml.createtextnode (newxml[" Time"])) - - case.appendchild (name) - case.appendchild (code) - case.appendchild (Result) in Case.appendchild (Time) - to Caselist.appendchild (case) + - theAdd_xml ({"ID":"1001","name":"login user name is correct, password is correct","Code":" $","result":"Test Pass"," Time":"2016-4-13"}) *filename = File ("Case.xml","W") $ xml.writexml (filename)Panax NotoginsengFilename.close ()
The resulting XML file contents are as follows:
1 <?XML version= "1.0"?>2 3 <!--Test Report -4-<caselist>-< CaseID= "1001"><name>Login user name is correct, password is correct</name><Code>200</Code><result>Test Pass</result>< Time>2016-4-13</ Time></ Case></caselist>
Python Learning Notes (XML generation)