I want to compare Technical Diploma (±12 years) with the same string present in the browser. I am running a webdriver test in Python where it fetches Technical Diploma (±12 years) from a db and tries to compare with a string present in the browser. I am getting this error when I try to compare
UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode – interpreting them as being unequal
How do I compare these non-ASCII strings in Python?
One of your strings is not a unicode value, but a bytestring. You want to convert that to unicode by decoding it first:
but you will have to figure out what encoding the bytestring is in in the first place.
If you have defined a source file encoding and you are defining the string as a literal in your code, make sure you define it as a Unicode literal by prefixing the string with a
u'':I strongly recommend you read up on the Python Unicode HOWTO before you proceed, however.