0

I have a test in which I need to click on the button located on the toolbar. This button does not have an ID, but it has the name of the class - ImageButton. How can I click on it using Espresso or Barista? I can not do this because I do not have id

onView(...).perform(click());

Trying to use Baristo, but this does not work:

click(withClassName(ImageButton.class));

1 Answers1

0

Create an id and use a robot class and invoke the method from uitest

fun clicksToolbarButton(): ActivityRobot {
    onView(withId(R.id.toolbar_button))
            .perform(scrollTo(), click())

    return this
  }
g7pro
  • 817
  • 1
  • 6
  • 11