XML Библиотека Robot Framework
Введение
Документация
Пример
robot_xml_demo/ ├── demo.xml └── tests └── robot └── test_demo.robot
<example> <first id="1">text</first> <second id="2"> <child/> </second> <third> <child>more text</child> <second id="child"/> <child><grandchild/></child> </third> <html> <p> Text with <b>bold</b> and <i>italics</i>. </p> </html> </example>
# test_demo.robot *** Settings *** Library XML Library Collections *** Variables *** ${XML}= demo.xml *** Test Cases *** Example ${root}= Parse XML ${XML} Should Be Equal ${root.tag} example ${first}= Get Element ${root} first Should Be Equal ${first.text} text Dictionary Should Contain Key ${first.attrib} id Element Text Should Be ${first} text Element Attribute Should Be ${first} id 1 Element Attribute Should Be ${root} id 1 xpath=first Element Attribute Should Be ${XML} id 1 xpath=first
Из директории robot_xml_demo выполним
python -m robot .\tests\robot\test_demo.robot
============================================================================== Test Demo ============================================================================== Read | PASS | ------------------------------------------------------------------------------ Test Demo | PASS | 1 test, 1 passed, 0 failed ==============================================================================
Автор статьи: Андрей Олегович
Operating System | |
RequestsLibrary | |
XML | |
Библиотеки | |
Robot Framework |