android - How to click Button adjacent to a specific text in Robotium -


i stuck @ problem wherein require click on specific button adjacent text in app.

for eg: let 1 of screens of app following text.

    xxxx-xxxx-xxxx  button1 button2     yyyy-yyyy-yyyy  button3 button4 

now want click on button1 if text passing input matches "xxxx-xxxx-xxxx". and, button3 if input text matches "yyyy-yyyy-yyyy".

https://www.dropbox.com/s/1fgr4uz4mm2mfm6/untitled.png refer link see how looks like.

thanks in advance!

i have made assumption in same viewgroup. if case not bad.

what need break down in set of problems

1) find view, pretty easy solo.gettext(string text) return text view has text or getedittext(string text) work if edit text.

2) find parent view in common between view found , button click. can calling getparent() on view returned above , casting (viewgroup)

3) find text view want view parent, simplest if have same structure use getchildat(i) on view group above, 2 strucutre mention. need cast button.

putting soemthing like:

view view = solo.getedittext("xxxx-xxxx-xxxx"); //or solo.gettext("xxxx-xxxx-xxxx") viewgroup viewgroupcontaingtextandbutton = (viewgroup) view.getparent(); button button = viewgroupcontaingtextandbutton.getchildat(2); 

you should able refactor nice easy re-usable method.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -