Skip to content Skip to sidebar Skip to footer

Pressing Buttons By 'text' On Android App Using Culebra

I have a Android App that I am trying to test using culebra. The code is shown below. '''reated on 2017-02-08 by Culebra v12.5.3 __ __ __ __

Solution 1:

Run

culebra -Gu -o myscript.py --scale=0.5

you'll see a window representing your device, much like

enter image description here

then you click on the buttons (I'm running ApiDemos here) and culebra generates

vc.dump(window=-1)
vc.findViewWithTextOrRaise(u'NORMAL').touch()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithTextOrRaise(u'SMALL').touch()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithTextOrRaise(u'OFF').touch()
vc.sleep(_s)
vc.dump(window=-1)

which you can then manually turn into

for t in ['NORMAL', 'SMALL', 'OFF']:
    b = vc.findViewWithTextOrRaise(t)
    print >> sys.stderr, "clicking", b,  "@", b.getXY()
    b.touch()

or even

for t in ['NORMAL', 'SMALL', 'OFF']:
    vc.findViewWithTextOrRaise(t).touch()

this is assuming the screen does not change when you click your buttons, if it does you need to call vc.dump() again.

Then you can copy and paste to your original script.

Post a Comment for "Pressing Buttons By 'text' On Android App Using Culebra"