Skip to content Skip to sidebar Skip to footer

Selenium Webdriver And Unicode

It's my 2nd day with Selenium 2 library and the pain with Unicode never seem to subside. I'm just doing the most basic operation, want to print the page source: from selenium impor

Solution 1:

You have options, based on this similar question.

You can either convert the source to all ascii losing the Unicode characters in the process.

(driver.page_source).encode('ascii', 'ignore')

Or, and I think you'll prefer this, you can encode it to utf-8 like this: (driver.page_source).encode('utf-8').

Solution 2:

Instead of print(string), use print(repr(string))to return a printable representation of the object.

Post a Comment for "Selenium Webdriver And Unicode"