I am getting "ASCII" errors trying use str.decode(), unicode.encode() and other functions. Can't understand how properly use it.
HTML code which I am trying to assest:
<div class="head">
<h1 id="localizationHeading">本地化</h1>
</div>
My assert script:
assert driver.find_element_by_id("localizationHeading").text == str.decode("本地化")
I also tried to use this script:
assert "本地化" in driver.find_element_by_id("localizationHeading").text
P.S. In the top of my code is # coding: utf-8
.
Error:
Traceback (most recent call last):
File "day2.py", line 53, in <module>
assert driver.find_element_by_id("localizationHeading").text == str.decode("
本地化")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal
not in range(128)
And these:
Traceback (most recent call last):
File "day2.py", line 52, in <module>
assert "本地化" in driver.find_element_by_id("localizationHeading").text
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal
not in range(128)
assert driver.find_element_by_id("localizationHeading").text == "本地化".decode().encode('utf-8')
also doesn't work - the same issue.