Skip to content

Commit 2e11e89

Browse files
authored
Merge pull request #1417 from Conengmo/newest-branca-selenium-tests
2 parents c12db38 + 1c07cde commit 2e11e89

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/selenium/test_selenium.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from html.parser import HTMLParser
55
import os
66
import subprocess
7+
from urllib.parse import unquote
78

89
import nbconvert
910
import pytest
@@ -72,9 +73,15 @@ def handle_starttag(self, tag, attrs):
7273
if tag == 'iframe':
7374
attrs = dict(attrs)
7475
if 'data-html' in attrs:
75-
html_base64 = attrs['data-html']
76+
data_html = attrs['data-html']
77+
if '%' in data_html[:20]:
78+
# newest branca version: data-html is percent-encoded
79+
html_bytes = unquote(data_html).encode()
80+
else:
81+
# legacy branca version: data-html is base64 encoded
82+
html_bytes = base64.b64decode(data_html)
7683
else: # legacy, can be removed when all notebooks have `data-html`.
7784
src = attrs['src']
7885
html_base64 = src.split(',')[-1]
79-
html_bytes = base64.b64decode(html_base64)
86+
html_bytes = base64.b64decode(html_base64)
8087
self.iframes.append(html_bytes)

0 commit comments

Comments
 (0)