(Robotium) Action bar up/home button click

前端 未结 3 1021
长发绾君心
长发绾君心 2021-01-06 04:42

I use Robotium as the library for Junit test for my Android application. I wrote some tests which works well. But when I try to write a test for native ActionBar\'s

3条回答
  •  滥情空心
    2021-01-06 05:28

    I use this function:

    public void clickOnActionBarHomeButton(Solo solo) {
        View homeView = solo.getView(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home : R.id.home);
        solo.clickOnView(homeView);
    }
    

    Maybe it's not a perfect decision, but it works.

提交回复
热议问题