Using Python and Selenium I'm crawling my website. I need to select values from drop-down menus in order to go from one page to the other.
One value I need to select is a"Brésil" and as you can see it contains non ascii letters.
I've added at the top of my document.
# -*- coding: utf-8 -*-
But when I try to assess the value from the element containing this string I'm stuck:
el = driver.find_element_by_xpath("/html/body/div/div[2]/ul/li[2]/select")
for option in el.find_elements_by_tag_name('option'):
if option.text == "Brésil":
option.click()
break
Here is the error message I get:
UnicodeWarning: Unicode equal comparison failed to convert both arguments to
Unicode - interpreting them as being unequal
if option.text == "Brésil":
I believe this is an encoding issue as my code works with any other strings which don't contain accentuated letters.
Any help would be greatly appreciated.
Thanks.