Appium, Android and Unicode: 'ascii' codec can't encode character

I’ve seen this issue. It’s been around for a while. Here is an old thread, with a fix:

https://groups.google.com/forum/#!topic/appium-discuss/-oPV4pvFbwo

And here is our fix in Ruby. We mix in the Selenium::WebDriver module and override ‘text’ in class Element and class Alert. Not exactly sure how to do it in Python, but between the above and this code you should be able to get it:

require 'unicode_utils'
module Selenium
  module WebDriver
    class Element
      def text
        UnicodeUtils.nfc bridge.getElementText @id
      end
    end

    class Alert

      def text
        UnicodeUtils.nfc @bridge.getAlertText
      end
    end
  end
end
1 Like