Skip to content

Commit 74d2eb6

Browse files
committed
v3.1.7 changes
1 parent 9909d4d commit 74d2eb6

File tree

6 files changed

+91
-27
lines changed

6 files changed

+91
-27
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Creates awesome HTML (dashboard view) report by parsing robotframework output.xm
1111
---
1212
- __Sample Report__ [link](https://robotmetrics.netlify.com/)
1313

14-
- Whats new in __v3.1.6__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.1.6)
14+
- Whats new in __v3.1.7__ [link](https://github.com/adiralashiva8/robotframework-metrics/releases/tag/v3.1.7)
1515

1616
- Source Code used to parse output.xml in metrics report [link](https://adiralashivaprasad.blogspot.com/2019/01/how-to-get-suite-test-and-keyword.html)
1717

@@ -93,6 +93,28 @@ Specify Logo in Robotframework metrics:
9393
```
9494
> By default `--ignorekeywords` is `False`
9595
96+
---
97+
98+
#### Exclude Logs in Metrics Report
99+
100+
- From `v3.1.7` users can exclude Logs tab in metrics report using `--ignorelogs` or `-l` command
101+
102+
```
103+
robotmetrics -l True
104+
```
105+
> By default `--ignorelogs` is `False`
106+
107+
---
108+
109+
#### Include Full Suite Name in Metrics Report
110+
111+
- From `v3.1.7` users can include full suite name in metrics report using `--fullsuitename` or `-s` command
112+
113+
```
114+
robotmetrics -s True
115+
```
116+
> By default `--fullsuitename` is `False`
117+
96118
97119
#### How to Ignore Library Keywords in Metrics Report
98120

robotframework_metrics/robotmetrics.py

+32-20
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def generate_report(opts):
125125
126126
.sidenav {
127127
height: 100%;
128-
width: 240px;
128+
width: 220px;
129129
position: fixed;
130130
z-index: 1;
131131
top: 0;
@@ -205,6 +205,11 @@ def generate_report(opts):
205205
hide_keyword = "hidden"
206206
else:
207207
hide_keyword = ""
208+
209+
if opts.ignorelogs == "True":
210+
hide_logs = "hidden"
211+
else:
212+
hide_logs = ""
208213

209214
soup = BeautifulSoup(head_content, "html.parser")
210215
body = soup.new_tag('body')
@@ -217,9 +222,9 @@ def generate_report(opts):
217222
<a class="tablink" href="#" onclick="openPage('suiteMetrics', this, '#fc6666'); executeDataTable('#sm',5)"><i class="fa fa-th-large" style="color:CADETBLUE"></i> Suite Metrics</a>
218223
<a class="tablink" href="#" onclick="openPage('testMetrics', this, '#fc6666'); executeDataTable('#tm',3)"><i class="fa fa-list-alt" style="color:PALEVIOLETRED"></i> Test Metrics</a>
219224
<a %s class="tablink" href="#" onclick="openPage('keywordMetrics', this, '#fc6666'); executeDataTable('#km',3)"><i class="fa fa-table" style="color:STEELBLUE"></i> Keyword Metrics</a>
220-
<a class="tablink" href="#" onclick="openPage('log', this, '#fc6666');"><i class="fa fa-wpforms" style="color:CHOCOLATE"></i> Logs</a>
225+
<a %s class="tablink" href="#" onclick="openPage('log', this, '#fc6666');"><i class="fa fa-wpforms" style="color:CHOCOLATE"></i> Logs</a>
221226
</div>
222-
""" % (logo, hide_keyword)
227+
""" % (logo, hide_keyword, hide_logs)
223228

224229
body.append(BeautifulSoup(icons_txt, 'html.parser'))
225230

@@ -541,9 +546,9 @@ def generate_report(opts):
541546

542547
# GET SUITE METRICS
543548
if group:
544-
group.spawn(result.visit, SuiteResults(soup, suite_tbody, log_name))
549+
group.spawn(result.visit, SuiteResults(soup, suite_tbody, log_name, opts.fullsuitename))
545550
else:
546-
result.visit(SuiteResults(soup, suite_tbody, log_name))
551+
result.visit(SuiteResults(soup, suite_tbody, log_name, opts.fullsuitename))
547552

548553
test_icon_txt = """
549554
<div class="row">
@@ -600,14 +605,18 @@ def generate_report(opts):
600605
th.string = "Error Message"
601606
tr.insert(4, th)
602607

608+
th = soup.new_tag('th')
609+
th.string = "Tags"
610+
tr.insert(5, th)
611+
603612
test_tbody = soup.new_tag('tbody')
604613
table.insert(11, test_tbody)
605614

606615
# GET TEST METRICS
607616
if group:
608-
group.spawn(result.visit, TestResults(soup, test_tbody, log_name))
617+
group.spawn(result.visit, TestResults(soup, test_tbody, log_name, opts.fullsuitename))
609618
else:
610-
result.visit(TestResults(soup, test_tbody, log_name))
619+
result.visit(TestResults(soup, test_tbody, log_name, opts.fullsuitename))
611620

612621
test_icon_txt = """
613622
<div class="row">
@@ -684,19 +693,22 @@ def generate_report(opts):
684693
# START OF LOGS
685694

686695
# Logs div
687-
log_div = soup.new_tag('div')
688-
log_div["id"] = "log"
689-
log_div["class"] = "tabcontent"
690-
page_content_div.insert(200, log_div)
691-
692-
test_icon_txt = """
693-
<p style="text-align:right">** <b>Report.html</b> and <b>Log.html</b> need to be in current folder in
694-
order to display here</p>
695-
<div class="embed-responsive embed-responsive-4by3">
696-
<iframe class="embed-responsive-item" src=%s></iframe>
697-
</div>
698-
""" % log_name
699-
log_div.append(BeautifulSoup(test_icon_txt, 'html.parser'))
696+
if opts.ignorelogs == "True":
697+
pass
698+
else:
699+
log_div = soup.new_tag('div')
700+
log_div["id"] = "log"
701+
log_div["class"] = "tabcontent"
702+
page_content_div.insert(200, log_div)
703+
704+
test_icon_txt = """
705+
<p style="text-align:right">** <b>Report.html</b> and <b>Log.html</b> need to be in current folder in
706+
order to display here</p>
707+
<div class="embed-responsive embed-responsive-4by3">
708+
<iframe class="embed-responsive-item" src=%s></iframe>
709+
</div>
710+
""" % log_name
711+
log_div.append(BeautifulSoup(test_icon_txt, 'html.parser'))
700712

701713
# END OF LOGS
702714
script_text = """

robotframework_metrics/runner.py

+14
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ def parse_options():
8080
help="Ignore keywords in metrics report"
8181
)
8282

83+
general.add_argument(
84+
'-l', '--ignorelogs',
85+
dest='ignorelogs',
86+
default="False",
87+
help="Ignore logs in metrics report"
88+
)
89+
90+
general.add_argument(
91+
'-s', '--fullsuitename',
92+
dest='fullsuitename',
93+
default="False",
94+
help="Use full suite name in report"
95+
)
96+
8397
args = parser.parse_args()
8498
return args
8599

robotframework_metrics/suite_results.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
class SuiteResults(ResultVisitor):
55

6-
def __init__(self, soup, tbody, log_name):
6+
def __init__(self, soup, tbody, log_name, full_suite_name):
77
self.soup = soup
88
self.tbody = tbody
99
self.log_name = log_name
10+
self.full_suite_name = full_suite_name
1011

1112
def start_suite(self, suite):
1213
suite_test_list = suite.tests
@@ -18,7 +19,10 @@ def start_suite(self, suite):
1819
self.tbody.insert(0, table_tr)
1920

2021
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal;cursor: pointer; color:blue; text-align:left")
21-
table_td.string = str(suite)
22+
if self.full_suite_name == "True":
23+
table_td.string = str(suite.longname)
24+
else:
25+
table_td.string = str(suite)
2226
table_td['onclick'] = "openInNewTab('%s%s%s','%s%s')" % (self.log_name, '#', suite.id, '#', suite.id)
2327
table_td['data-toggle'] = "tooltip"
2428
table_td['title'] = "Click to view '%s' logs" % suite

robotframework_metrics/test_results.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33

44
class TestResults(ResultVisitor):
55

6-
def __init__(self, soup, tbody, logname):
6+
def __init__(self, soup, tbody, logname, full_suite_name):
77
self.soup = soup
88
self.tbody = tbody
99
self.log_name = logname
10+
self.full_suite_name = full_suite_name
1011

1112
def visit_test(self, test):
1213
table_tr = self.soup.new_tag('tr')
1314
self.tbody.insert(0, table_tr)
1415

1516
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 200px; white-space: normal; text-align:left")
16-
table_td.string = str(test.parent)
17+
if self.full_suite_name == "True":
18+
try:
19+
full_suite_name = test.longname.split("." + test.name)
20+
table_td.string = str(full_suite_name[0])
21+
except Exception as e:
22+
table_td.string = str(test.parent)
23+
else:
24+
table_td.string = str(test.parent)
1725
table_tr.insert(0, table_td)
1826

1927
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal;cursor: pointer; color:blue; text-align:left")
@@ -39,4 +47,8 @@ def visit_test(self, test):
3947

4048
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width: 250px; white-space: normal;text-align:left")
4149
table_td.string = test.message
42-
table_tr.insert(4, table_td)
50+
table_tr.insert(4, table_td)
51+
52+
table_td = self.soup.new_tag('td', style="word-wrap: break-word;max-width:100px; white-space: normal;text-align:left")
53+
table_td.string = str(test.tags)
54+
table_tr.insert(5, table_td)

robotframework_metrics/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.6"
1+
__version__ = "3.1.7"

0 commit comments

Comments
 (0)