1, coverage package implementation code Coverage (1) pip install coverage (2) Coverage run xx.py (test script file) (3) Coverage report-m print out Coverage Information Report (4) coverage in the console HTML generates a Htmlcov file in the same directoryfolder, open index.html in folders to view code coverage in a graphical interface 2, Xpath Understanding(1) XPath is a language that looks for information in an XML document. XPath is used to navigate through elements and attributes in an XML document. 3, XPath basic Syntax http://www.w3school.com.cn/example/xmle/books.xml (1) slash/select from the root node, representing the absolute path (2) double slash//relative path, as long as the condition of the display exercise:
Select all the parent elements are the BBB element syntax for DDD://DDD/BBB
<AAA>
<BBB/>
<CCC/>
<BBB/>
<DDD>
<BBB/>
</DDD>
<CCC>
<DDD>
<BBB/>
<BBB/>
</DDD>
</CCC>
</AAA>
Selects all BBB element syntax for the AAA's CCC:/aaa/ccc//bbb
<AAA>
<BBB/>
<CCC/>
<BBB/>
<DDD>
<BBB/>
</DDD>
<CCC>
<DDD>
<BBB/>
<BBB/>
</DDD>
</CCC>
</AAA>
(3) point "." Select the current node
(2) point "..." Select the parent node of the current node
(4) [@] Property Select all Category property choose the book element with the Category property to select All Properties category= "Web" or "category=" by selecting the book element with the category= "cooking" property Paperback "element selects a book element with any attribute select an element relative to an attribute that does not have a property lookup (5) find the first element
Select the first BBB element syntax under AAA:/aaa/bbb[1]
< AAA >
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
(6) Select the last BBB element under AAA syntax:/aaa/bbb[last ()]
< AAA >
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
(7) Select the second-lowest BBB element under AAA syntax:/aaa/bbb[last ()-1]
< AAA >
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
(8) Select the first two BBB element syntax under AAA:/aaa/bbb[position () <3]
< AAA >
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
(9) Obtain the CCC element syntax under the BBB under the AAA with the S attribute:/aaa/bbb/ccc[@s]
<AAA>
<BBB>
<CCCs = "1"/>
<CCCs = "2"/>
<CCCs = "3"/>
<CCCs = "4"/>
<CCCs = "5"/>
<CCC r = "a"/>
</BBB>
<CCC>
<BBB r = "a"/>
<BBB r = "B"/>
<BBB r = "C"/>
</CCC>
<BBB/>
<BBB/>
</AAA>
"Python" xpath-1