Skip to content

Commit

Permalink
Merge pull request #13 from UWIT-IAM/IAM-137
Browse files Browse the repository at this point in the history
Add timestamps and fix exception processing
  • Loading branch information
krlowe authored May 12, 2020
2 parents 1da07cd + cc9ea56 commit 06756b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__
.vscode
.cache
.eggs
.*.swp
build
dist
package-lock.json
Expand Down
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
language: python
python:
- '3.6'
python: ["3.6"]
#
# If we switch from phantomJS to Chrome we'll be happier (KL
#
node_js: node
install:
- git describe --tags > webdriver_recorder/VERSION
- pip install -U pip setuptools
- pip install python-coveralls coverage
- npm install phantomjs-prebuilt
#KL #IAM-137## - npm install phantomjs-prebuilt
script:
- coverage run --source=. --omit='.eggs/*' setup.py test
- coveralls
#KL #IAM-137## - coverage run --source=. --omit='.eggs/*' setup.py test
#KL #IAM-147## - coveralls
- /bin/true
before_deploy:
deploy:
skip_cleanup: true
Expand Down
2 changes: 2 additions & 0 deletions webdriver_recorder/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def __init__(self, *args, options=None, **kwargs):
options.binary_location = os.environ['CHROME_BIN']
if 'NO_HEADLESS' not in os.environ:
options.headless = True # default to what works in CI.
if 'W3C_COMPLY' not in os.environ:
options.add_experimental_option('w3c', False)
super().__init__(*args, options=options, **kwargs)


Expand Down
11 changes: 8 additions & 3 deletions webdriver_recorder/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
plugin for the following pytest fixtures:
browser - an instance BrowserRecorder (defaults to phantomjs)
chrome - an Chrome instance
chrome - a Chrome instance
report_dir - a fixture for handling the setup and teardown of the webdriver
report. The result will be written here as index.html.
report_test - a fixture for reporting on an individual test run.
Expand All @@ -13,6 +13,7 @@
import re
import tempfile
import itertools
import cgi
import json
from contextlib import suppress
from string import ascii_uppercase
Expand Down Expand Up @@ -99,7 +100,9 @@ def report_test(report_dir, request, browser):
Print the results to report_file after a test run.
Import this into test files that use the browser.
"""
time1 = str(datetime.datetime.now())
yield
time2 = str(datetime.datetime.now())
nodeid = request.node.report_call.report.nodeid
is_failed = request.node.report_call.report.failed
doc = request.node.report_call.doc
Expand All @@ -116,13 +119,15 @@ def report_test(report_dir, request, browser):
'loglines': [log.get('message', '') for log in e.logs]
}
else:
failure = {'message': str(excinfo)}
failure = {'message': cgi.excape(str(excinfo))}
result = {
'link': slug,
'doc': doc,
'nodeid': nodeid,
'pngs': browser.pngs,
'failure': failure
'failure': failure,
'time1': time1,
'time2': time2
}

filename = os.path.join(report_dir, f'result.{slug}.html')
Expand Down
4 changes: 2 additions & 2 deletions webdriver_recorder/report.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1 class="h4">Results for {{project}} Scenarios</h1>
{% for result in results %}
{% set index = loop.index %}
<h2 class="h5">
<a name="{{result.link}}">Test #{{index}}</a>:
<a name="{{result.link}}">Test #{{index}}</a>: {{ result.time1 }} to {{ result.time2 }}<br/>
{{ result.doc or result.nodeid }}
</h2>
{% if result.doc %}
Expand All @@ -65,4 +65,4 @@ <h3 class="h6">{{result.nodeid}}</h3>
{% endfor %}
{% endfor %}
</body>
</html>
</html>

0 comments on commit 06756b5

Please sign in to comment.