0

I am trying to automate a test case where i have to delete the data in EditText first , then enter new text and save it . i am using androidviewclient to find the views . enter code here Busy = vc.findViewByIdOrRaise('id/no_id/24') Busy.touch() vc.dump() id16 = vc.findViewByIdOrRaise('id/no_id/16')

id16 is the Edit Text , how to erase data in that view . please help

user
  • 65
  • 1
  • 11

2 Answers2

0

If the View is an EditText you can do:

id16 = vc.findViewByIdOrRaise('id/no_id/16')
for i in range(25):
    id16.backspace()
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Can you please also let me know how to get the status of a radio button . my scenario is something like this : navigate to call barring , check if the service is enabled . navigation would be : Phone > Settings > GSM call settings > Call Barring > Outgoing barring > All calls . All calls has a radio button for which i have if the button is enabled or not . please help – user Nov 21 '13 at 10:24
  • See http://stackoverflow.com/questions/19510146/how-can-i-get-the-status-of-check-box, if not enough just create a new question. – Diego Torres Milano Nov 22 '13 at 06:05
  • I have created a new question http://stackoverflow.com/questions/20138987/how-to-get-the-status-of-radio-button-using-androidviewclient , please help – user Nov 27 '13 at 05:07
0

for EditText containing some data you can do this:

view= vc.findViewById(ID)    
if view.getClass()=='android.widget.EditText':
    textPresent=view.getText()
    for i in range(len(textPresent)):
        view.backspace()
    print 'removed existing text'`

Though it deletes one character at a time and thus consumes lot of time for long strings