Reputation: 19
I have the source code for the ImageView
ImageView topbarCalender = (ImageView) view.findViewById(R.id.pf_topbarCalender);
I want to click on image using robotium. I used the following code for it
ImageButton image1 = (ImageButton) solo.getView("pf_topbarCalender");
solo.clickOnView(image1);
Its not working. My test is failing.
Upvotes: 0
Views: 1794
Reputation: 1
enterView view = solo.getView("pf_topbarCalender");
solo.clickOnView(view);
Some times doesn't work on Android 6. And I use next method:
solo.clickOnImageButton(index);
Parameters: index - the index of the ImageButton to click. 0 if only one is available
But on different divices image button can have different indexes.
Upvotes: 0
Reputation: 6597
The second approach worked for me:
View view = solo.getView(R.id.pf_topbarCalender);
solo.clickOnView(view);
Upvotes: -2
Reputation: 706
Use this:
ImageButton image1 = (ImageButton) solo.getView("pf_topbarCalender");
solo.clickOnImageButton(image1);
or
View view = solo.getView("pf_topbarCalender");
solo.clickOnView(view);
Upvotes: 3