user2387855
user2387855

Reputation: 314

Why won't Robotium acknowledge checkboxes with higher index values that are further down the page?

My test keeps returning junit.framework.AssertionFailedError: 6 CheckBoxs are not found! when call

if(!solo.isCheckBoxChecked(5)){
    solo.clickOnCheckBox(5);            
}

I don't understand why it is doing this because it scrolls down by itself (while watching the phone this is apparent). Based on the documentation I think this should make it like solo.clickOnText which scrolls around until it either finds it or gives up. Also I have used the exact same if statement with several check-boxes with lower index values and it never failed. There are 7 check-boxes on the page.

Upvotes: 0

Views: 170

Answers (1)

maszter
maszter

Reputation: 3720

Index is not the best way to identify views. If I'm not wrong, robotium indexes only visible views, so if you scroll down, indexes for views will change. This way, you have always visible views (different) but with the same indexes. Try to use text or R.id, if you have different for every checkbox.

For instance you can see 3 checkboxes (indexes 0-2), scroll down, you still see 3 checkboxes (indexes 0-2), but different, indexes are rewritten to the visible ones. I may be wrong, but I don't think I am.

Upvotes: 1

Related Questions