(Robotium) Action bar up/home button click

0
0

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 Up/Home button click, it failed.

My test code is very simple:

Solo solo = new Solo(getInstrumentation(), getActivity());
...
solo
.clickOnActionBarHomeButton(); // I expected it will click the Up/Home button of ActionBar

I expected the above code will click the Up/Home button of native ActionBar, but it is failed, nothing was happening on action bar. Why??

P.S. I am using an Android 4.2.1 device.

  • You must to post comments
0
0

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.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website