Several representations of ID in Robotium 1) string form: For example Id/btn_example, the source of the layout in some of the hierachy see is this. 2) Digital form: For example 0x7f0700d, open R.java inside reflects the string form and int form correspondence relation. White box test, directly use the form of r.id to call the View View =solo.getview (r.id.btn_example);//Get Viewsolo.clickonview (view);//Click on the Black box test, r.id Invisible Activity Act =solo.getcurrentactivity ();//Get Activityint ID =act.getresources (). Getidentifier ("Btn_example", "id" , Act.getpackagename ());//Get int's Idview View =act.findviewbyid (ID) by string ID;//Get Viewsolo.clickonview (view);// Click on the method can be encapsulated, the method is as follows: Private Boolean Clickbyid (String id) throws exception{ if (id== "") { return false; } try{ Activity Act =solo.ge Tcurrentactivity ();//Gets the current activity int id = Act.getresource (). Getidentifier (ID, "id", Solo.getcurrentactivity (). Getpackagename ());//Get id view view = Solo.getview (ID);//Get View Solo.clickonview (view);//click view }catch (exception ex) {  LOG.E (); } return true;}
Get View by ID in Robotium and do the appropriate action