0

I am trying to automate sending of MMS using a monkey runner script which is a python script.I am getting the co-ordinates from hierarchy viewer for touch/press functions.But the problem is all these events work on the main screen.I mean if there is forground screen such as list of options that pops up when attachment option is selected in SMS window.How can i get co-ordinates or select such options.

from com.dtmilano.android.viewclient import ViewClient

displayView = findViewWithAttribute('text:Pictures', 'Display')
#displayView.touch()

Here i am trying to select "Pictures" option and touch it but the code fails to work.Please help.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
Brinda
  • 21
  • 1
  • Are you trying to select this from the **Attach** dialog (Pictures, Capture picture, Videos, etc.). Please describe the steps you took and what you really expect. – Diego Torres Milano May 09 '13 at 15:06
  • yes,thats right.I need to attach picture from gallery and for this i need to select "Pictures".But the problem is that the script never selects the "pictures options" but selects the same co-ordinates on the background UI which is the compose message screen.I am trying to select "pictures" option which appears as a foreground screen. – Brinda May 11 '13 at 16:28
  • Hey guys!!Any answers..?? struggling to find the solution..pls help. – Brinda May 14 '13 at 10:23

1 Answers1

0

Let's say you open MMS, start a New Message, and then press Attach

enter image description here

when this dialog is displayed you run culebra as

$ culebra -C -t on -o mms-attach.py

edit generated mm-attach.py to remove unneeded parts and add the touch() method. Your script would be something like this:

#! /usr/bin/env shebang monkeyrunner -plugin $ANDROID_VIEW_CLIENT_HOME/bin/androidviewclient-$ANDROID_VIEW_CLIENT_VERSION.jar @!
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013  Diego Torres Milano
Created on 2013-05-14 by Culebra v0.9.8

                      __    __    __    __
                     /  \  /  \  /  \  /  \ 
____________________/  __\/  __\/  __\/  __\_____________________________
___________________/  /__/  /__/  /__/  /________________________________
                   | / \   / \   / \   / \   \___
                   |/   \_/   \_/   \_/   \    o \ 
                                           \_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''


import re
import sys
import os


from com.dtmilano.android.viewclient import ViewClient

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device, serialno, autodump=False)
vc.dump(window='-1')

# unneeded views removed

# class=android.widget.TextView text="Pictures"
no_id14 = vc.findViewWithTextOrRaise('Pictures')
no_id14.touch()

you run it, and then Pictures is selected and now your are in the Choose picture screen as desired.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134