on-internet
← Community

How to lcoate a specific context menu item using androidx.test.uiautomator?

Stack Overflow ·

I am developing a few UI tests using Android's UIAutomator. For one of them I want to long-click an item and then select a menu-entry from the appearing Context-Menu of said item. I would prefer to be able to select the menu-item using the id from the "R"-file (like "R.id.xyz"), i.e. I want to be able to write something like item.longClick(); // select item's context menu UiObject2 menuEntry = findMenuEntry(device, R.id.ctxt_duplicate); menuEntry.click(); where findMenuEntry() would be a utility method like: public static UiObject2 findMenuEntry(final UiDevice device, final int id) { final Sea

Comments

Sign in or sign up to comment and upvote.

No comments yet.