Robot framework spits out an output XML which is then used to build the HTML reports (with rebot
), re-run failures, etc.
I need to parse this file to generate other reports, in particular, I need to parse the test case's documentation for a regex, get the test case result and then build a report (this is for integration with a legacy system).
Does Robot Framework provide functionality to easily parse the output XML file or we just use standard XML parsing libraries?
Introduction. While Robot Framework is running tests, it generates an XML output file containing all information about the execution. After execution is over it creates, by default, log and report files using rebot tool internally.
Robot Framework library for verifying and modifying XML documents. As the name implies, XML is a library for verifying contents of XML files. In practice, it is a pretty thin wrapper on top of Python's ElementTree XML API.
You can use the keyword Get File from the OperatingSystem library to read the file, and you can use the Split to Lines keyword from the String library to convert the file contents to a list of lines. Then it's just a matter of looping over the lines using a for loop.
You just have to identify the stop point, which in your example looks like it would be the hyphen between the two number values. for example: to extract the last five digits of this string ABC12345 you would want to create a variable to assign the text to.
Ok, found 3 viable responses:
DbBot
and query the DB created.xml.etree.ElementTree
is pretty simple.visit_test
method.Ended up with going with option 3 as that is part of Robot Framework and less likely to break (or easier to fix) if the format of the XML file changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With