Appium could not get actual DOM of screen

On certain screens appium can’t find specific element by selector when it is existing and dipsplayed on it. I’ve noticed that appium for some reason is not able to grab full screen DOM or actual screen DOM. When I trying to get page source through Appium Inspector, I see current element in the next format please pay attention to @resource-id attribute:
<android.widget.TextView index="16" package="com.***.***.***.***" class="android.widget.TextView" text="certain_text" resource-id="some_id" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[929,1763][1036,1805]" displayed="true" />

XPath selector that I’m using: //*[@resource-id=“some_id”]. And Appium Inspector is able to find current element and show it in App Source window by this xpath selector.

But when I trying to get page DOM using driver.getPageSource() I see that current element doesn’t has @resource-id attribute. Here is how it look:
<android.widget.TextView index="16" package="com.***.***.***.***" class="android.widget.TextView" text="certain_text" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[929,1763][1036,1805]" displayed="true" />

The similar situation is with uiautomatorviewer tool, here is how it looks in XML dump of screen that I made:
<node index="16" text="certain_text" resource-id="some_id" class="android.widget.TextView" package="com.***.***.***.***" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[929,1982][1036,1988]" /></node>

I’ve tried wait for element and just wait for certain amount of time, run app in background for short time, lock and unlock screen, change selector strategy from xpath to UIAutomator but nothing seems to work.

Is there some way to get only actual DOM of screen? Or situation is really hopeless?

Languge: JavaScript

Versions:
“appium”: “^1.22.3”
@wdio/appium-service”: “^7.25.4”,
@wdio/cli”: “^7.19.6”,
@wdio/local-runner”: “^7.19.5”,
@wdio/mocha-framework”: “^7.19.5”,
@wdio/spec-reporter”: “^7.19.5”,

hi, i don’t want to be wrong but i don’t think you can write (in your code) an xpath with //*[@resource-id=‘some id’]. if appium inspector finds the element, probably the path is wrong.

Current type of selector works fine and Appium Inspector finds current element by it. The problem is related how Appium Inspector and Appium package sees page source, and as it shown in upper examples for some reason package is not able to identify @resource-id attribute

have you tried to use …

AppiumBy.androidUIAutomator("new UiSelector().resourceId(\"resource-id\")"

?

Yep, the same thing. I get an error that current element does not exist. I am still convinced that it is problem with appium and how it get page source (as shown in example above)

  1. check your code
  2. right after fail get page source and compare with your code
  3. can you write your full resource-id as is just replacing few chars and code you trying?