Import sys
From Com. Android. monkeyrunner import monkeyrunner, monkeydevice
Device = monkeyrunner. waitforconnection ()
# Remove installed app coupon
Device. removepackage ('com. tu23.800.123.upon ')
Print 'remove success! '
# Install app coupon
Device. installpackage ('d:/tua0packages/androidpackag23e/coup.apk ')
Print 'Install success! '
# Start app coupon
Device. startactivity (Component = 'com. tu00.coupon/COM. tu00.coupon. Activities. Splash ')
Print 'start success! '
Monkeyrunner. Sleep (10)
# The screen is drag from page1 to start page
For I in range (1, 4 ):
Device. Drag (200,100), (5,100), 0.2, 10)
Print I
Result = device. takesnapshot ()
Result. writetofile ('e:/workspace/androidyouhuiscreenshot/shot'{str( I ?#'.png ', 'png ')
Device. Touch (150,300, monkeydevice. down_and_up)
# Get the current shot
Result = device. takesnapshot ()
# Writes the screenshot to a file
Result. writetofile ('e:/workspace/androidyouhuiscreenshot/shot11.png ', 'png ')
Monkeyrunner. Sleep (10)
# Select city Beijing
Device. Touch (150,206, 'down _ and_up ')
Monkeyrunner. Sleep (10)
# Get the current shot Beijing
Result = device. takesnapshot ()
# Writes the screenshot to a file
Result. writetofile ('e:/workspace/androidyouhuiscreenshot/beijing.png ', 'png ')
# Select city Guangzhou
# Device. Touch (150,300, 'down _ and_up ')