UnicodeDecodeError raised by driver.page_source

Hello,

all of a sudden, I cannot use driver.page_source on some of the pages of the app I am testing. It’s been working for several years, but now I get the UnicodeDecodeError, on some pages immediately, on same pages after I make some operations on them.

I really don’t understand what has changes, because I have not made any changes in packages/library lately. Do you have any ideas?

Thank for the help!

I am using Python 3.12, Appium-Python-Client 4.1.0.

The whole error here:

.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:448: in page_source
    return self.execute(Command.GET_PAGE_SOURCE)["value"]
.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:345: in execute
    response = self.command_executor.execute(driver_command, params)
.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:302: in execute
    return self._request(command_info[0], url, body=data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <appium.webdriver.appium_connection.AppiumConnection object at 0x00000162A435D430>
method = 'GET'
url = 'http://127.0.0.1:4723/session/ccac1b22-847f-42e6-a96c-575966088bae/source'
body = None

    def _request(self, method, url, body=None):
        """Send an HTTP request to the remote server.
    
        :Args:
         - method - A string for the HTTP method to send the request with.
         - url - A string for the URL to send the request to.
         - body - A string for request body. Ignored unless method is POST or PUT.
    
        :Returns:
          A dictionary with the server's parsed JSON response.
        """
        parsed_url = parse.urlparse(url)
        headers = self.get_remote_connection_headers(parsed_url, self.keep_alive)
        response = None
        if body and method not in ("POST", "PUT"):
            body = None
    
        if self.keep_alive:
            response = self._conn.request(method, url, body=body, headers=headers)
            statuscode = response.status
        else:
            conn = self._get_connection_manager()
            with conn as http:
                response = http.request(method, url, body=body, headers=headers)
            statuscode = response.status
>       data = response.data.decode("UTF-8")
E       UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 15896: invalid start byte

.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:329: UnicodeDecodeError

Please provide the full server log. Also make sure you use the most recent driver and server versions

I got Appium v2.11.3 with uiautomator2 v3.7.7

And I realized I am not able to obtain server logs. I start Appium Service in a way shown in Appium-Python-Client · PyPI using session fixture, but when I read the log it creates, it contains just few line and from which I assume, that something starts the server before (the port is not available), which quite confuses me. What am I doing wrong? :slight_smile:

2024-08-30 06:41:27:096 [Appium] Welcome to Appium v2.11.3
2024-08-30 06:41:27:099 [Appium] Non-default server args:
2024-08-30 06:41:27:101 [Appium] { address: '127.0.0.1' }
2024-08-30 06:41:27:101 [Appium] The autodetected Appium home path: C:\Users\KarelVrabka\.appium
2024-08-30 06:41:27:102 [Appium] Attempting to load driver uiautomator2...
2024-08-30 06:41:27:104 [Appium] Requiring driver at C:\Users\KarelVrabka\.appium\node_modules\appium-uiautomator2-driver\build\index.js
2024-08-30 06:41:28:443 [Appium] AndroidUiautomator2Driver has been successfully loaded in 1.341s
2024-08-30 06:41:28:466 [HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.

EDIT:
I switched the port for the server and now it works, log is here:
service_log.log (2.6 MB)

From the log I got, that when, getPageSource line looks like this

2024-08-30 07:38:32:181 [99ef65cb]e[38;5;-110m[AndroidUiautomator2Driver@9a89] Matched '/source' to command name 'getPageSource'

then it works. But it fails on this

2024-08-30 07:38:46:139 [99ef65cb]e[38;5;-110m[AndroidUiautomator2Driver@9a89] Matched '/session/99ef65cb-b90e-48d8-b86e-91ea47a0e440/source' to command name 'getPageSource'

Could it be the case? And if so, what is the reason?

From the server perspective everything looks fine in the above log.

It would make sense to retrieve the failing xml page source (e.g. the response data) to a file and analyze it. this could be done by setting an exception breakpoint and then sending the request to the server via curl or any other http client and saving it locally.

This is the data from response:

{
“sessionId”: “04fac2e1-6a3a-40b2-a1e0-047cf1a7fae7”,
“value”: “<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<hierarchy index="0" class="hierarchy" rotation="0" width="800" height="1256">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][800,1280]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][800,1256]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,1256]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/action_bar_root" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,1256]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="android:id/content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,1256]" displayed="true">\r\n <android.widget.ScrollView index="0" package="com.sensus.config" class="android.widget.ScrollView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,1256]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,120]" displayed="true">\r\n <android.view.ViewGroup index="0" package="com.sensus.config" class="android.view.ViewGroup" text="" resource-id="com.sensus.config:id/toolbar" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][800,120]" displayed="true">\r\n <android.widget.ImageButton index="0" package="com.sensus.config" class="android.widget.ImageButton" text="" content-desc="Open navigation drawer" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,36][84,120]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="2021-000-0099" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[108,57][315,98]" displayed="true" />\r\n <androidx.appcompat.widget.LinearLayoutCompat index="2" package="com.sensus.config" class="androidx.appcompat.widget.LinearLayoutCompat" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[524,36][800,120]" displayed="true">\r\n <android.widget.Button index="0" package="com.sensus.config" class="android.widget.Button" text="" content-desc="Filter" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[524,42][596,114]" displayed="true" />\r\n <android.widget.Button index="1" package="com.sensus.config" class="android.widget.Button" text="" content-desc="Clear read data" resource-id="com.sensus.config:id/refresh_option" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[596,42][668,114]" displayed="true" />\r\n <android.widget.Button index="2" package="com.sensus.config" class="android.widget.Button" text="" content-desc="Write configuration" resource-id="com.sensus.config:id/action_apply_configuration" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[668,42][740,114]" displayed="true" />\r\n <android.widget.ImageView index="3" package="com.sensus.config" class="android.widget.ImageView" text="" content-desc="More options" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="true" password="false" scrollable="false" selected="false" bounds="[740,42][800,114]" displayed="true" />\r\n </androidx.appcompat.widget.LinearLayoutCompat>\r\n </android.view.ViewGroup>\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="1" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/toolbar_activity_main_content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <androidx.drawerlayout.widget.DrawerLayout index="0" package="com.sensus.config" class="androidx.drawerlayout.widget.DrawerLayout" text="" resource-id="com.sensus.config:id/drawer_layout" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <androidx.slidingpanelayout.widget.SlidingPaneLayout index="0" package="com.sensus.config" class="androidx.slidingpanelayout.widget.SlidingPaneLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="com.sensus.config:id/list_fragment_container" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.RelativeLayout index="0" package="com.sensus.config" class="android.widget.RelativeLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.view.ViewGroup index="0" package="com.sensus.config" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <androidx.recyclerview.widget.RecyclerView index="0" package="com.sensus.config" class="androidx.recyclerview.widget.RecyclerView" text="" resource-id="com.sensus.config:id/meter_list" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="com.sensus.config:id/card_view" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="true" password="false" scrollable="false" selected="false" bounds="[3,120][797,210]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/content_layout" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[7,126][793,204]" displayed="true">\r\n <android.widget.RelativeLayout index="0" package="com.sensus.config" class="android.widget.RelativeLayout" text="" resource-id="com.sensus.config:id/status_box" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[19,135][79,195]" displayed="true">\r\n <android.widget.ImageView index="0" package="com.sensus.config" class="android.widget.ImageView" text="" resource-id="com.sensus.config:id/status_icon" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[19,135][79,195]" displayed="true" />\r\n </android.widget.RelativeLayout>\r\n <android.widget.FrameLayout index="1" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="com.sensus.config:id/card_content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,132][781,198]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/content_lines" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,132][781,198]" displayed="true">\r\n <android.widget.RelativeLayout index="0" package="com.sensus.config" class="android.widget.RelativeLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,132][781,165]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="2021-000-0099" resource-id="com.sensus.config:id/address_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,132][259,165]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="" resource-id="com.sensus.config:id/meter_id_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[259,132][652,165]" displayed="true" />\r\n <android.widget.TextView index="2" package="com.sensus.config" class="android.widget.TextView" text="Aug 30, 12:39" resource-id="com.sensus.config:id/time_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[652,135][781,164]" displayed="true" />\r\n </android.widget.RelativeLayout>\r\n <android.widget.RelativeLayout index="1" package="com.sensus.config" class="android.widget.RelativeLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,165][781,198]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Repeater" resource-id="com.sensus.config:id/meter_type_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[91,168][235,197]" displayed="true" />\r\n <android.widget.LinearLayout index="1" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/signal_strength_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[235,165][585,198]" displayed="true">\r\n <android.widget.ImageView index="0" package="com.sensus.config" class="android.widget.ImageView" text="" resource-id="com.sensus.config:id/signal_strength_icon" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[374,171][395,192]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="97%" resource-id="com.sensus.config:id/signal_value_text" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[401,165][445,198]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.TextView index="2" package="com.sensus.config" class="android.widget.TextView" text="" resource-id="com.sensus.config:id/reading_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[585,165][781,198]" displayed="true" />\r\n </android.widget.RelativeLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.FrameLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.FrameLayout>\r\n </androidx.recyclerview.widget.RecyclerView>\r\n <android.widget.ImageButton index="1" package="com.sensus.config" class="android.widget.ImageButton" text="" resource-id="com.sensus.config:id/fab" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[692,1148][776,1232]" displayed="true" />\r\n </android.view.ViewGroup>\r\n </android.widget.RelativeLayout>\r\n </android.widget.FrameLayout>\r\n <android.widget.FrameLayout index="1" package="com.sensus.config" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="com.sensus.config:id/multi_pane_detail_container" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.RelativeLayout index="0" package="com.sensus.config" class="android.widget.RelativeLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,1256]" displayed="true">\r\n <android.widget.HorizontalScrollView index="0" package="com.sensus.config" class="android.widget.HorizontalScrollView" text="" resource-id="com.sensus.config:id/meter_config_tab_layout" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,192]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,120][800,192]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" content-desc="General" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="true" bounds="[0,120][127,192]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="GENERAL" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="true" bounds="[18,141][109,170]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.HorizontalScrollView>\r\n <androidx.viewpager.widget.ViewPager index="1" package="com.sensus.config" class="androidx.viewpager.widget.ViewPager" text="" resource-id="com.sensus.config:id/meter_config_view_pager" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,192][800,1256]" displayed="true">\r\n <android.widget.ScrollView index="0" package="com.sensus.config" class="android.widget.ScrollView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,192][800,1256]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/tab_container" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,192][800,1180]" displayed="true">\r\n <android.widget.FrameLayout index="0" package="com.sensus.config" class="android.widget.FrameLayout" text="" resource-id="com.sensus.config:id/card_repeater_general_basic" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[12,192][788,1180]" displayed="true">\r\n <android.widget.LinearLayout index="0" package="com.sensus.config" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,198][784,1174]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="BASIC" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,198][760,270]" displayed="true" />\r\n <android.widget.LinearLayout index="1" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/fep_status_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,270][760,325]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Status" resource-id="com.sensus.config:id/fep_status_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,279][461,316]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="0" resource-id="com.sensus.config:id/fep_status_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,279][760,316]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="2" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/origin_serial_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,325][760,380]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Origin serial" resource-id="com.sensus.config:id/origin_serial_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,334][461,371]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="210000099" resource-id="com.sensus.config:id/origin_serial_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,334][760,371]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="3" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/number_of_telegrams_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,380][760,435]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Number of telegrams" resource-id="com.sensus.config:id/number_of_telegrams_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,389][461,426]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="2" resource-id="com.sensus.config:id/number_of_telegrams_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,389][760,426]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="4" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/actuality_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,435][760,490]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Actuality" resource-id="com.sensus.config:id/actuality_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,444][461,481]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="Aug 30, 10:14" resource-id="com.sensus.config:id/actuality_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,444][760,481]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="5" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/repeater_type_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,490][760,545]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Repeater type" resource-id="com.sensus.config:id/repeater_type_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,499][461,536]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="REPEATER_V1" resource-id="com.sensus.config:id/repeater_type_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,499][760,536]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="6" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/time_interval_for_auto_activation_view" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,545][760,612]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Time interval for auto activation" resource-id="com.sensus.config:id/time_interval_for_auto_activation_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,560][461,597]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="7 hours" resource-id="com.sensus.config:id/time_interval_for_auto_activation_value" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,554][760,603]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="7" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/timeout_for_auto_activation_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,612][760,667]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Timeout of auto activation" resource-id="com.sensus.config:id/timeout_of_auto_activation_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,621][461,658]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="7 seconds" resource-id="com.sensus.config:id/timeout_of_auto_activation_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,621][760,658]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="8" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/transmission_inteval_f1_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,667][760,722]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Transmission interval F1" resource-id="com.sensus.config:id/transmission_inteval_f1_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,676][461,713]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="15 seconds" resource-id="com.sensus.config:id/transmission_inteval_f1_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,676][760,713]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="9" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/transmission_inteval_f2_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,722][760,777]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Transmission interval F2" resource-id="com.sensus.config:id/transmission_inteval_f2_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,731][461,768]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="30 seconds" resource-id="com.sensus.config:id/transmission_inteval_f2_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,731][760,768]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="10" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/actual_lifetime_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,777][760,832]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Actual lifetime" resource-id="com.sensus.config:id/actual_lifetime_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,786][461,823]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="3584 days" resource-id="com.sensus.config:id/actual_lifetime_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,786][760,823]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="11" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/alarm_check_configuration_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,832][760,887]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Event check configuration" resource-id="com.sensus.config:id/alarm_check_configuration_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,841][461,878]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="3845" resource-id="com.sensus.config:id/alarm_check_configuration_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,841][760,878]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="12" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/used_pam_buffer_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,887][760,942]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Used PAM buffer" resource-id="com.sensus.config:id/used_pam_buffer_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,896][461,933]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="false" resource-id="com.sensus.config:id/used_pam_buffer_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,896][760,933]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="13" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/power_save_interval_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,942][760,997]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Power save interval" resource-id="com.sensus.config:id/power_save_interval_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,951][461,988]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="14700 ms" resource-id="com.sensus.config:id/power_save_interval_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,951][760,988]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="14" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/remaining_battery_capacity_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,997][760,1052]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Remaining battery capacity" resource-id="com.sensus.config:id/remaining_battery_capacity_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1006][461,1043]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="52%" resource-id="com.sensus.config:id/remaining_battery_capacity_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,1006][760,1043]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="15" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/temperature_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1052][760,1107]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Temperature" resource-id="com.sensus.config:id/temperature_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1061][461,1098]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="25 �C" resource-id="com.sensus.config:id/temperature_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,1061][760,1098]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n <android.widget.LinearLayout index="16" package="com.sensus.config" class="android.widget.LinearLayout" text="" resource-id="com.sensus.config:id/number_of_devices_in_alarm_chain_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1107][760,1162]" displayed="true">\r\n <android.widget.TextView index="0" package="com.sensus.config" class="android.widget.TextView" text="Number of devices in event chain" resource-id="com.sensus.config:id/number_of_devices_in_alarm_chain_label" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1116][461,1153]" displayed="true" />\r\n <android.widget.TextView index="1" package="com.sensus.config" class="android.widget.TextView" text="0" resource-id="com.sensus.config:id/number_of_devices_in_alarm_chain_value" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[479,1116][760,1153]" displayed="true" />\r\n </android.widget.LinearLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.FrameLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.ScrollView>\r\n </androidx.viewpager.widget.ViewPager>\r\n <android.view.View index="2" package="com.sensus.config" class="android.view.View" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,192][800,204]" displayed="true" />\r\n </android.widget.RelativeLayout>\r\n </android.widget.FrameLayout>\r\n </android.widget.FrameLayout>\r\n </androidx.slidingpanelayout.widget.SlidingPaneLayout>\r\n </androidx.drawerlayout.widget.DrawerLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.ScrollView>\r\n </android.widget.FrameLayout>\r\n </android.widget.LinearLayout>\r\n </android.widget.FrameLayout>\r\n </android.widget.LinearLayout>\r\n <android.view.View index="2" package="com.sensus.config" class="android.view.View" text="" resource-id="android:id/navigationBarBackground" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1256][800,1280]" displayed="true" />\r\n </android.widget.FrameLayout>\r\n”}

I can see the wrongly decoded symbols, should be °C and the are decoded correctly on the device screen. Don’t know why the are not in the XML.

This could be a bug in the Android’s XML implementation. Let me try to run some unit tests to check that

Does the app you are testing release new versions? Does this problem coincide with a new release candidate, and if so, if you were to go back to a previous release, does the problem still exist?

I have validated it with unit tests that properly encoded unicode texts are passed properly to the downstream response. Might it be that the application under test does not properly expose unicode characters to the accessbility or encode them not in UTF-8?

Perhaps you could try to get a page source dump with adb to be able to compare as described in android - Is there a way to get current activity's layout and views via adb? - Stack Overflow

I tried the versions which worked just fine in the past, but the same problem with encoding now. And the problem does not occur with different devices, is it possible that it is device side problem?

The dump works just fine.

yes, it might be that custom devices contain somme buggy code not handling unicode chars properly

I just don’t understand that it stopped working all of the sudden. For several years there has been no problems.

Maybe some non-decodable stuff has been added to the app UI recently.

I’ve added a patch related to the XML attributes encoding to the UIA2 server and published it in the driver version 3.7.9. Please try it and see if that helps

We started getting a similar error across platform Android-iOS. So I doubt it has something to do with the app UI. Maybe it’s related to the base-driver handling JSON requests/responses?

I found out, that when you switch to different language in the app settings and back to english, the decoding will work correct for strings which existed before the language switch. But once some new strings with unicode characters appears, it will raise the error again. Since our app works with dynamic data, this ‘fix’ is not usable, but for a moment I thought I finally found a way.

I noticed it happens only after a few sessions… if I restart the appium server it works for some time