我在试一根绳子。我得到了innerHTML,但是它有额外的u'\n
和\n'
AssertionError: u'\n<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>\n' != '<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>'
来自网站的HTML
<div id="errorDiv1" class="error" style="display: block;">
<p><strong>Codul de Utilizator/Codul introduse nu sunt corecte!</strong></p>
</div>
代码
error = self.driver.find_element_by_id("errorDiv1").get_attribute('innerHTML')
expected_error = '<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>'
self.assertEqual(error, expected_error)
这里发生了什么?他们从哪里来?你知道吗
\n
是新行字符。你知道吗它的出现是因为在HTML代码的第1行和第2行之间有一个新行字符。你知道吗
u''
在pythonUnicode Strings中定义Unicode字符串。你知道吗'\n'
是一个转义序列,代表Linefeed。换行是指将打印区域前进一行。你知道吗相关问题 更多 >
编程相关推荐