Skip to content

Commit

Permalink
Merge pull request #22 from adiralashiva8/show_suite_test_keyword_met…
Browse files Browse the repository at this point in the history
…rics_in_email

Show suite, test and keyword metrics in email
  • Loading branch information
adiralashiva8 authored Sep 7, 2018
2 parents 033d433 + df07ba0 commit c25e942
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 73 deletions.
Binary file removed Images/Email_Statistics_Email.png
Binary file not shown.
Binary file added Images/Email_Statistics_Email_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ __ROBOT LOG__
![Screenshot](Images/Email_Statistics.png)
![Screenshot](Images/Email_Statistics_Email.png)
![Screenshot](Images/Email_Statistics_Email_new.png)
---
Expand All @@ -96,7 +96,7 @@ __ROBOT LOG__
*Versions:*
1. V2.1 [link](https://github.com/adiralashiva8/robotframework-metrics/archive/v2.1.zip)
1. V2.2 [link](https://github.com/adiralashiva8/robotframework-metrics/archive/v2.2.zip)
> Status: __Beta__
> 1. Dashboard
Expand Down
74 changes: 45 additions & 29 deletions rf_metrics_report_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ def start_keyword(self,kw):
executeDataTable('#tm',5);
executeDataTable('#km',5);
createPieChart(%s,%s,'suiteChartID','Suite Status:');
createBarGraph('#sm',0,4,10,'suiteBarID','Top 10 Suite Performance:');
createBarGraph('#sm',0,4,10,'suiteBarID','Top 10 Suite Performance:','Suite');
createPieChart(%s,%s,'testChartID','Tests Status:');
createBarGraph('#tm',1,5,10,'testsBarID','Top 10 Tests Performance:');
createBarGraph('#tm',1,5,10,'testsBarID','Top 10 Tests Performance:','Test');
createPieChart(%s,%s,'keywordChartID','Keywords Status:');
createBarGraph('#km',1,5,10,'keywordsBarID','Top 10 Keywords Performance:')
createBarGraph('#km',1,5,10,'keywordsBarID','Top 10 Keywords Performance:','Keyword')
};
</script>
</div>
Expand Down Expand Up @@ -771,9 +771,22 @@ def start_keyword(self,kw):
emailStatistics="""
<h4><b><i class="fa fa-envelope-o"></i> Email Statistics</b></h4>
<hr>
<h6><ul><li>Click 'Generate Statistics Email' button to get generate statistics email</li><li>Click 'Click Here To Download Email' link to download generated email</ul></h6>
<button id="create" class="btn btn-primary active" role="button" ><i class="fa fa-cogs"></i> Generate Statistics Email</button><br><br>
<a download="message.eml" class="btn btn-secondary active" role="button" id="downloadlink" style="display: none; width: 300px;font-weight: bold;"><i class="fa fa-download"></i> Click Here To Download Email</a>
<button id="create" class="btn btn-primary active" role="button" onclick="updateTextArea();this.style.visibility= 'hidden';"><i class="fa fa-cogs"></i> Generate Statistics Email</button>
<a download="message.eml" class="btn btn-primary active" role="button" id="downloadlink" style="display: none; width: 300px;font-weight: bold;"><i class="fa fa-download"></i> Click Here To Download Email</a>
<script>
function updateTextArea() {
var suite = "<b>Top 10 Suite Performance:</b><br><br>" + $("#suiteBarID table")[0].outerHTML;
var test = "<b>Top 10 Test Performance:</b><br><br>" + $("#testsBarID table")[0].outerHTML;
var keyword ="<b>Top 10 Keyword Performance:</b><br><br>" + $("#keywordsBarID table")[0].outerHTML;
var saluation="<pre><br>Please refer RF Metrics Report for detailed statistics.<br><br>Regards,<br>QA Team</pre></body></html>";
document.getElementById("textbox").value += "<br>" + suite + "<br>" + test + "<br>" + keyword + saluation;
$("#create").click(function(){
$(this).remove();
});
}
</script>
<textarea id="textbox" class="col-md-12" style="height: 400px; padding:1em;">
To: [email protected]
Subject: Automation Execution Status
Expand All @@ -783,7 +796,7 @@ def start_keyword(self,kw):
<html>
<head>
<style>
body, html, table,pre {
body, html, table,pre,b {
font-family: Calibri, Arial, sans-serif;
font-size: 1em;
}
Expand All @@ -792,6 +805,7 @@ def start_keyword(self,kw):
border: 1px solid silver;
padding: 6px;
margin-left: 30px;
width: 600px;
}
thead {
text-align: center;
Expand All @@ -800,17 +814,23 @@ def start_keyword(self,kw):
font-weight: bold;
color: #2D2C2C;
}
tbody td {
tbody {
text-align: center;
}
th {
width: 25%%;
word-wrap:break-word;
}
</style>
</head>
<body>
<pre>Hi Team,
Following are the last build execution statistics.
<b>Metrics:<b>
</pre>
<table style="width: 600px;">
<table>
<thead>
<th style="width: 25%%;">Statistics</th>
<th style="width: 25%%;">Total</th>
Expand All @@ -819,33 +839,29 @@ def start_keyword(self,kw):
</thead>
<tbody>
<tr>
<td style="text-align: left;font-weight: bold;padding-left: 40px;"> SUITE </td>
<td style="background-color: #F5DEB3;">%s</td>
<td style="background-color: #90EE90;">%s</td>
<td style="background-color: #F08080;">%s</td>
<td style="text-align: left;font-weight: bold;"> SUITE </td>
<td style="background-color: #F5DEB3;text-align: center;">%s</td>
<td style="background-color: #90EE90;text-align: center;">%s</td>
<td style="background-color: #F08080;text-align: center;">%s</td>
</tr>
<tr>
<td style="text-align: left;font-weight: bold;padding-left:40px;"> TESTS </td>
<td style="background-color: #F5DEB3;">%s</td>
<td style="background-color: #90EE90;">%s</td>
<td style="background-color: #F08080;">%s</td>
<td style="text-align: left;font-weight: bold;"> TESTS </td>
<td style="background-color: #F5DEB3;text-align: center;">%s</td>
<td style="background-color: #90EE90;text-align: center;">%s</td>
<td style="background-color: #F08080;text-align: center;">%s</td>
</tr>
<tr>
<td style="text-align: left;font-weight: bold;padding-left: 40px;"> KEYWORDS </td>
<td style="background-color: #F5DEB3;">%s</td>
<td style="background-color: #90EE90;">%s</td>
<td style="background-color: #F08080;">%s</td>
<td style="text-align: left;font-weight: bold;"> KEYWORDS </td>
<td style="background-color: #F5DEB3;text-align: center;">%s</td>
<td style="background-color: #90EE90;text-align: center;">%s</td>
<td style="background-color: #F08080;text-align: center;">%s</td>
</tr>
</tbody>
</table>
<pre>
Please refer RF Metrics Report for detailed statistics.
Regards,
QA Team</pre>
</body>
</html>
</textarea>
""" % (total_suite,passed_suite,failed_suite,total,passed,failed,total_keywords,passed_keywords,failed_keywords)
statisitcs_div.append(BeautifulSoup(emailStatistics, 'html.parser'))

Expand Down Expand Up @@ -912,7 +928,7 @@ def start_keyword(self,kw):
}
</script>
<script>
function createBarGraph(tableID,keyword_column,time_column,limit,ChartID,ChartName){
function createBarGraph(tableID,keyword_column,time_column,limit,ChartID,ChartName,type){
var status = [];
css_selector_locator = tableID + ' tbody >tr'
var rows = $(css_selector_locator);
Expand All @@ -929,7 +945,7 @@ def start_keyword(self,kw):
'#76A032',
'#34558B'
];
status.push(['Year', 'Elaspsed Time(s)',{ role: 'annotation'}, {role: 'style'}]);
status.push([type, 'Elapsed Time(s)',{ role: 'annotation'}, {role: 'style'}]);
for (var i = 0; i < rows.length; i++) {
if (i == Number(limit)){
break;
Expand Down
86 changes: 44 additions & 42 deletions rf_metrics_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -974,28 +974,28 @@ <h4>
</b>
</h4>
<hr/>
<h6>
<ul>
<li>
Click 'Generate Statistics Email' button to get generate statistics email
</li>
<li>
Click 'Click Here To Download Email' link to download generated email
</li>
</ul>
</h6>
<button class="btn btn-primary active" id="create" role="button">
<button class="btn btn-primary active" id="create" onclick="updateTextArea();this.style.visibility= 'hidden';" role="button">
<i class="fa fa-cogs">
</i>
Generate Statistics Email
</button>
<br/>
<br/>
<a class="btn btn-secondary active" download="message.eml" id="downloadlink" role="button" style="display: none; width: 300px;font-weight: bold;">
<a class="btn btn-primary active" download="message.eml" id="downloadlink" role="button" style="display: none; width: 300px;font-weight: bold;">
<i class="fa fa-download">
</i>
Click Here To Download Email
</a>
<script>
function updateTextArea() {
var suite = "<b>Top 10 Suite Performance:</b><br><br>" + $("#suiteBarID table")[0].outerHTML;
var test = "<b>Top 10 Test Performance:</b><br><br>" + $("#testsBarID table")[0].outerHTML;
var keyword ="<b>Top 10 Keyword Performance:</b><br><br>" + $("#keywordsBarID table")[0].outerHTML;
var saluation="<pre><br>Please refer RF Metrics Report for detailed statistics.<br><br>Regards,<br>QA Team</pre></body></html>";
document.getElementById("textbox").value += "<br>" + suite + "<br>" + test + "<br>" + keyword + saluation;
$("#create").click(function(){
$(this).remove();
});
}
</script>
<textarea class="col-md-12" id="textbox" style="height: 400px; padding:1em;">
To: [email protected]
Subject: Automation Execution Status
Expand All @@ -1005,7 +1005,7 @@ <h6>
<html>
<head>
<style>
body, html, table,pre {
body, html, table,pre,b {
font-family: Calibri, Arial, sans-serif;
font-size: 1em;
}
Expand All @@ -1014,6 +1014,7 @@ <h6>
border: 1px solid silver;
padding: 6px;
margin-left: 30px;
width: 600px;
}
thead {
text-align: center;
Expand All @@ -1022,17 +1023,23 @@ <h6>
font-weight: bold;
color: #2D2C2C;
}
tbody td {
tbody {
text-align: center;
}
th {
width: 25%;
word-wrap:break-word;
}
</style>
</head>
<body>
<pre>Hi Team,
Following are the last build execution statistics.

</pre>
<table style="width: 600px;">
<b>Metrics:<b>

</b></b></pre>
<table>
<thead>
<th style="width: 25%;">Statistics</th>
<th style="width: 25%;">Total</th>
Expand All @@ -1041,33 +1048,28 @@ <h6>
</thead>
<tbody>
<tr>
<td style="text-align: left;font-weight: bold;padding-left: 40px;"> SUITE </td>
<td style="background-color: #F5DEB3;">2</td>
<td style="background-color: #90EE90;">2</td>
<td style="background-color: #F08080;">0</td>
<td style="text-align: left;font-weight: bold;"> SUITE </td>
<td style="background-color: #F5DEB3;text-align: center;">2</td>
<td style="background-color: #90EE90;text-align: center;">2</td>
<td style="background-color: #F08080;text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: left;font-weight: bold;padding-left:40px;"> TESTS </td>
<td style="background-color: #F5DEB3;">6</td>
<td style="background-color: #90EE90;">6</td>
<td style="background-color: #F08080;">0</td>
<td style="text-align: left;font-weight: bold;"> TESTS </td>
<td style="background-color: #F5DEB3;text-align: center;">6</td>
<td style="background-color: #90EE90;text-align: center;">6</td>
<td style="background-color: #F08080;text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: left;font-weight: bold;padding-left: 40px;"> KEYWORDS </td>
<td style="background-color: #F5DEB3;">24</td>
<td style="background-color: #90EE90;">24</td>
<td style="background-color: #F08080;">0</td>
<td style="text-align: left;font-weight: bold;"> KEYWORDS </td>
<td style="background-color: #F5DEB3;text-align: center;">24</td>
<td style="background-color: #90EE90;text-align: center;">24</td>
<td style="background-color: #F08080;text-align: center;">0</td>
</tr>
</tbody>
</table>
<pre>
Please refer RF Metrics Report for detailed statistics.

Regards,
QA Team</pre>
</body>
</html>
</textarea>

</body></html></textarea>
</div>
<div class="tabcontent" id="dashboard">
<h4>
Expand Down Expand Up @@ -1295,11 +1297,11 @@ <h4 class="text-center" style="font-size:13px">
executeDataTable('#tm',5);
executeDataTable('#km',5);
createPieChart(2,0,'suiteChartID','Suite Status:');
createBarGraph('#sm',0,4,10,'suiteBarID','Top 10 Suite Performance:');
createBarGraph('#sm',0,4,10,'suiteBarID','Top 10 Suite Performance:','Suite');
createPieChart(6,0,'testChartID','Tests Status:');
createBarGraph('#tm',1,5,10,'testsBarID','Top 10 Tests Performance:');
createBarGraph('#tm',1,5,10,'testsBarID','Top 10 Tests Performance:','Test');
createPieChart(24,0,'keywordChartID','Keywords Status:');
createBarGraph('#km',1,5,10,'keywordsBarID','Top 10 Keywords Performance:')
createBarGraph('#km',1,5,10,'keywordsBarID','Top 10 Keywords Performance:','Keyword')
};
</script>
</div>
Expand Down Expand Up @@ -1360,7 +1362,7 @@ <h4 class="text-center" style="font-size:13px">
}
</script>
<script>
function createBarGraph(tableID,keyword_column,time_column,limit,ChartID,ChartName){
function createBarGraph(tableID,keyword_column,time_column,limit,ChartID,ChartName,type){
var status = [];
css_selector_locator = tableID + ' tbody >tr'
var rows = $(css_selector_locator);
Expand All @@ -1377,7 +1379,7 @@ <h4 class="text-center" style="font-size:13px">
'#76A032',
'#34558B'
];
status.push(['Year', 'Elaspsed Time(s)',{ role: 'annotation'}, {role: 'style'}]);
status.push([type, 'Elapsed Time(s)',{ role: 'annotation'}, {role: 'style'}]);
for (var i = 0; i < rows.length; i++) {
if (i == Number(limit)){
break;
Expand Down

0 comments on commit c25e942

Please sign in to comment.