user2724402
user2724402

Reputation: 19

Unable to click on ImageView in Robotium

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

Answers (3)

Alexandr Kohanchyk
Alexandr Kohanchyk

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

Juangui Jordán
Juangui Jordán

Reputation: 6597

The second approach worked for me:

View view = solo.getView(R.id.pf_topbarCalender); 
solo.clickOnView(view);

Upvotes: -2

Flavio Capaccio
Flavio Capaccio

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

Related Questions