Issue with instrumented mode of execution

I executed two lines of script to tap on an element after installing and launching the app with instrumented mode. I checked the instrument checkbox before the execution started.

When in Instrumented mode, I copy the XPath and paste it in code and run it, it is not identifiable during run time, and it returns as the element not found. So, after the execution, I spied the same screen again, and it was in non-instrumented mode. Here my confusion is, how the app is turned into non-instrumented mode after setting up the in the capability as true for instrumentation (dc.setCapability(“instrumentApp”, true)

How we can verify the current page is Instrumented or not by code itself at the time of the execution or How to change Instrumented Mode if the page is not instrumented.

Help me… Is there any dependency do we need to add to execute the app in instrumented mode?

Let me know if u need any screenshot and logs for this issue.

Thanks in advance.

Is this an ios, or android, native application ?? or is this a web app ? Please add a screen shot showing the object spy dump of your UI.

Not enough detail in your description to understand what is happening

it’s in Android App , native application.