DataMatcher locator strategy examples?

Hi, please provide examples of how to use Espresso’s DataMatcher? (Java is preferable)

I have done following test request

{
    "using": "-android datamatcher",
    "value": "{\"name\": \"hasEntry\",\"args\": [\"tag\", \"welcome\"]}"
}

But the result is:

"An unknown server-side error occurred while processing the command. Original error: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: is assignable from class: class android.widget.AdapterView\n\nView Hierarchy:\n+>DecorView{ …

Would be helpful also a data example of selector string for Appium Desktop.

currently, providing a JSON doesn’t work

{
      "name": "hasEntry",
      "args": ["tag", "welcome"]
}

The data is JSON according to DataMatcherJson.kt:24 as it is parsed by Gson.
The strategy name is correct according to JavaHamcrest.
Args are set according to espresso-datamatcher-selector doc.

But getting an exception.

Please use the API Demo apk https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/ApiDemos-debug.apk

Get into Views and execute the below code

JSONObject orderJSON = new JSONObject();
JSONArray objects = new JSONArray();
objects.put(“title”);
objects.put(“TextClock”);
orderJSON.put(“name”, “hasEntry”);
orderJSON.put(“args”, objects);
((AndroidDriver) driver).findElementByAndroidDataMatcher(orderJSON.toString()).click();

Thank you @saikrishna321 for the example. It works on that app.

I wondered how can I access to resourceID or the element’s tag using datamatcher, is it possible to locate elements like we are able to do with other locator strategies?

Here are some succeeded requests on ApiDemos-debug.apk

{
    "using": "-android datamatcher",
    "value": "{\"args\":[\"title\",\"Text\"],\"name\":\"hasEntry\"}"
}

or another one

{
    "using": "-android datamatcher",
    "value": "{\"args\":\"Text\",\"name\":\"hasValue\"}"
}

Also, an issue was found at testing after requesting “hasProperty”

{
    "using": "-android datamatcher",
    "value": "{\"args\":\"text\",\"name\":\"hasProperty\"}"
}

something gets broken and after that, every datamatcher request ends up with “Error: socket hang up”:

{
    "status": 13,
    "value": {
        "message": "An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: socket hang up"
    },
    "sessionId": "b8861a74-e140-4aee-95ea-9cf3921be547"
}

session restart is needed to have the datamatcher working again.