Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_rendering_utf8_iframe():
iframe = elem.IFrame(html=u'<p>Cerrahpaşa Tıp Fakültesi</p>')
options = Options()
options.add_argument('-headless')
driver = Firefox(options=options)
driver.get('data:text/html,' + iframe.render())
driver.switch_to.frame(0)
assert u'Cerrahpaşa Tıp Fakültesi' in driver.page_source
def render(self, **kwargs):
"""Renders the HTML representation of the element."""
html = super(IFrame, self).render(**kwargs)
html = "data:text/html;charset=utf-8;base64," + base64.b64encode(html.encode('utf8')).decode('utf8') # noqa
if self.height is None:
iframe = (
'<div style="width:{width};">'
'<div style="position:relative;width:100%;height:0;padding-bottom:{ratio};">' # noqa
''
'</div></div>'
).format(html=html, width=self.width, ratio=self.ratio)
else:
iframe = (
''
).format(html=html, width=self.width, height=self.height)