I'm tryng to test some app using monkeyrunner and AndroidViewClient, also I have used culebra to generate code, But I have this erro:
from com.dtmilano.android.viewclient import ViewClient, TextView, EditText
SyntaxError: ("mismatched input 'as' expecting COLON", ('/home/experts/AndroidViewClient-master/src/com/dtmilano/android/viewclient.py', 3795, 35, ''))
This is my script whit monkeyrunner and AndroidViewClient
import re
import sys
import os
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient, TextView, EditText
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
def main():
# Connects to the current device, returning a MonkeyDevice object
emulatorid = 'emulator-5558'
device = MonkeyRunner.waitForConnection('',emulatorid)
print "waiting for connection...\n"
package = "com.duolingo"
activity = "app.LoginActivity"
# sets the name of the component to start
runComponent = package + "/." + activity
#Runs the component
print "Start Component"
device.startActivity(component=runComponent)
MonkeyRunner.sleep(10)
vc = ViewClient(device)
vc.dump()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithTextOrRaise(u'GET STARTED').touch()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithTextOrRaise(u'Spanish', root=self.vc.findViewByIdOrRaise('id/no_id/3')).touch()
# Takes a screenshot
screenshot = device.takeSnapshot()
# Writes the screenshot to a file
screenshot.writeToFile('./device1.png','png')
print "end"
if __name__ == '__main__':
main()
If I execute this wthiout monkeyrunner it show an erro about "ViewClient(device)", This script is inside an loop (for).
EDIT:
I executed culebra and now I have my scripts running fine!! But, it works by CommandLine ($ myscripttest.py emulator-5554) If I call it using subprocess.call, where emulatorid='emulator-5554'
subprocess.call('path/script_files/myscripttest.py' + ' ' + emulatorid, shell=True)
it shows an error:
File "/path/script_files/myscripttest.py", line 9, in <module>
from com.dtmilano.android.viewclient import ViewClient
File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.0.7-py2.7.egg/com/dtmilano/android/viewclient.py", line 43, in <module>
import xml.parsers.expat
File "/usr/lib/python2.7/xml/parsers/expat.py", line 4, in <module>
from pyexpat import *
ImportError: /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt
I verify with this code: Where is the error?
$ ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
linux-vdso.so.1 => (0x00007fffe5dc2000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f55d2fd4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f55d2c0f000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f55d29e5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f55d3403000)