Skip to content

Commit 6063dc5

Browse files
authored
Add TestingBot video to html report correctly (#204)
1 parent 50f7574 commit 6063dc5

File tree

3 files changed

+19
-37
lines changed

3 files changed

+19
-37
lines changed

pytest_selenium/drivers/testingbot.py

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ def pytest_selenium_capture_debug(item, report, extra):
4646
if not provider.uses_driver(item.config.getoption("driver")):
4747
return
4848

49+
session_id = item._driver.session_id
50+
auth_url = get_auth_url(
51+
"https://testingbot.com/tests/{}.mp4".format(session_id), provider, session_id
52+
)
4953
pytest_html = item.config.pluginmanager.getplugin("html")
50-
extra.append(pytest_html.extras.html(_video_html(item._driver.session_id)))
54+
extra.append(pytest_html.extras.html(_video_html(auth_url, session_id)))
5155

5256

5357
@pytest.mark.optionalhook
@@ -97,47 +101,25 @@ def driver_kwargs(request, test, capabilities, host, port, **kwargs):
97101
return kwargs
98102

99103

100-
def _video_html(session):
101-
flash_vars = 'config={{\
102-
"clip":{{\
103-
"url":"{session}",\
104-
"provider":"rtmp"}},\
105-
"plugins":{{\
106-
"controls":{{\
107-
"url":"http://testingbot.com/assets/\
108-
flowplayer.controls-3.2.14.swf",\
109-
"mute":null,\
110-
"volume":null}},\
111-
"rtmp":{{\
112-
"url":"http://testingbot.com/assets/\
113-
flowplayer.rtmp-3.2.11.swf",\
114-
"netConnectionUrl":"rtmp://s2tuay45tyrz3f.cloudfront.net/\
115-
cfx/st"}}}},\
116-
"playerId":"mediaplayer{session}",\
117-
"playlist":[{{\
118-
"url":"{session}",\
119-
"provider":"rtmp"}}]}}'.format(
120-
session=session
121-
)
122-
104+
def _video_html(video_url, session):
123105
return str(
124106
html.div(
125-
html.object(
126-
html.param(value="true", name="allowfullscreen"),
127-
html.param(value="always", name="allowscriptaccess"),
128-
html.param(value="high", name="quality"),
129-
html.param(value="#000000", name="bgcolor"),
130-
html.param(value="opaque", name="wmode"),
131-
html.param(value=flash_vars.replace(" ", ""), name="flashvars"),
107+
html.video(
108+
html.source(src=video_url, type="video/mp4"),
132109
width="100%",
133110
height="100%",
134-
type="application/x-shockwave-flash",
135-
data="http://testingbot.com/assets/flowplayer-3.2.14.swf",
136-
name="mediaplayer_api",
137-
id="mediaplayer_api",
111+
controls="controls",
138112
),
139113
id="mediaplayer{session}".format(session=session),
140114
style="border:1px solid #e6e6e6; float:right; height:240px;"
141115
"margin-left:5px; overflow:hidden; width:320px",
142116
)
143117
)
118+
119+
120+
def get_auth_url(url, provider, session_id):
121+
from hashlib import md5
122+
123+
key = "{0.key}:{0.secret}:{1}".format(provider, session_id)
124+
token = md5(key.encode("utf-8")).hexdigest()
125+
return "{}?auth={}".format(url, token)

testing/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def webtext(base_url, selenium):
4343
filterwarnings =
4444
error::DeprecationWarning
4545
ignore:--firefox-\w+ has been deprecated:DeprecationWarning
46-
""",
46+
""", # noqa: W605
4747
)
4848

4949
def runpytestqa(*args, **kwargs):

testing/test_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_exclude_debug_env(testdir, httpserver, monkeypatch, exclude):
132132

133133

134134
@pytest.mark.parametrize("exclude", ["url", "screenshot", "html", "logs"])
135-
def test_exclude_debug_config(testdir, httpserver, monkeypatch, exclude):
135+
def test_exclude_debug_config(testdir, httpserver, exclude):
136136
httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
137137
testdir.makefile(
138138
".ini",

0 commit comments

Comments
 (0)