'Espresso Web Find Element with title

Given the following html:

<a class="MDB ABC" href="#" target="_self" data-my-id="wid-close"
 role="button" aria-label="Close" style="color:#000000 !important;" title="Close">

The above html does not contain any id or name which I can use to identify this in Espresso. I want to use aria-label or title or the custom one data-my-id in my espresso findElement.

Can someone tell me if there a way to add any of the above?

Below is an example which works when we have id:

onWebView(withId(R.id.webview))
.withElement(findElement(Locator.ID, "signup-button"))
.perform(webClick());

I want something like

.withElement(findElement(title , "Close"))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source