Espresso click menu item

后端 未结 7 1113
感动是毒
感动是毒 2020-12-14 16:11

I have a menu in the actionbar which I create through:

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    menu.add(Menu.NONE, 98,Menu.NONE,R.stri         


        
7条回答
  •  攒了一身酷
    2020-12-14 16:57

    You can use this method to click menu item. First click menu button using this code

    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    

    Then perform click menu item based on text.Replace your menu item name with "MenuItemName"

    onView(withText("MenuItemName")).perform(click());
    

提交回复
热议问题