Creates HTML Metrics report based on robotframework output.xml.
- Read output.xml file using robotframework API
- Get Suite, Test Case , Keyword , Status and Elapsed time values
- Convert data to html report using Beautifulsoup
-
Download robotmetrics.py from here link
-
Copy robotmetrics.py file to project
-
Install beautifulsoup: (to create html report - one time activity)
pip install beautifulsoup4
-
Execute robotmetrics.py file
Case 1: robotmetrics.py is copied where output.xml is available
python robotmetrics.py
Case 2: Specify output.xml file path. (When .xml and .html file names are same)
python robotmetrics.py -inputpath .\Result\
Case 3: Specify file name. (When .xml and .html file names are altered)
python robotmetrics.py -inputpath .\Result\ -output voutput.xml -report vreport.html -log vlog.html
-
RobotFramework Metrics Report metric-timestamp.html file will be created in current folder |
-inputpath
if specified -
Email will be sent to mentioned recepient with metric-timestamp.html file
Specify Logo and custom links in Robotframework metrics:
-
Custom Logo : Customize your logo by modifying robotmetrics.py file at line no: 21
logo = "https://cdn.pixabay.com/photo/2016/08/02/10/42/wifi-1563009_960_720.jpg"
-
Custom Links : You can customize your links in report by modifying robotmetrics.py file at line no: 309-320. Modify href and text
<ul class="nav flex-column mb-2"> <li class="nav-item"> <a style="color:blue;" class="tablink nav-link" target="_blank" href="https://www.github.com"> <i class="fa fa-external-link"></i> Git Hub </a> </li> <li class="nav-item"> <a style="color:blue;" class="tablink nav-link" target="_blank" href="https://www.jira.com"> <i class="fa fa-external-link"></i> JIRA </a> </li> </ul>
-
In robotmetrics.py file add specific TO, FROM, SUBJECT, EMAIL server and etc., info (line no:98-113)
if send_email in ['true', '1', 't', 'y', 'yes']: server = smtplib.SMTP('smtp.gmail.com:587') msg = MIMEMultipart() msg['Subject'] = 'MyProject Automation Status' sender = '[email protected]' recipients = ['[email protected]', '[email protected]'] ccrecipients = ['[email protected]', '[email protected]'] msg['From'] = sender msg['To'] = ", ".join(recipients) msg['Cc'] = ", ".join(ccrecipients) password = "*************"
-
By default email will be sent to mentioned recpients when .py file is executed. Using -email false (or) -email f can disable send email.
python robotmetrics.py -email false
-
Email will be sent when following condition is met
-email true | 1 | t | y | yes
- In robotmetrics.py file add specific library keywords ignore_library
- In Metric report, keywords with type value 'for' and 'foritem' are ignored
- Following library keywords are ignored in Metrics Report
ignore_library = [ 'BuiltIn', 'SeleniumLibrary', 'String', 'Collections', 'DateTime', ]
Execute .py file after suite or test execution as follows:
-
Create .bat (or) .sh file with following snippet
robot test.robot && python robotmetrics.py
&& is used to execute multiple command's in .bat file
-
Modify robot command as required and execute .bat file
-
Robotframework metrics will be created after execution
Thanks for using robotframework-metrics!
- What is your opinion of this report?
- What’s the feature I should add?
If you have any questions / suggestions / comments on the report, please feel free to reach me on [email protected]
Credits:
- Robotframework link
- Stackoverflow link
- Google charts link
- DataTable link
- BeautifulSoup link
- Jquery | JavaScript link
- Bootstrap link
- Icons8 link
- FontAwesome link