You are doing something rather strange here:
View actionbarItem1 = solo.getView(2);
The solo.getView(int id) method takes a view identifier from R.id. (like a way)
You have a class in a file called R.java, where all identifiers are listed. When you create a view, it generates an identifier for your view. Each identifier corresponds to a view.
public static final class id { public static final int fancy_action_item_id=0x7f07016a; }
The findViewById(int id) method will help you get the view you want by giving it an identifier. Perhaps you should continue this path:
View actionBarItem1 = yourActivity.findViewById(R.id.fancy_action_item_id); solo.clickOnView(actionBarItem1);
source share