I am really new to python, Cmonkeyrunner and android. I am trying to automate android application and using dtmilano AndroidViewClient
I have installed python 2.7.9 on Windows 8, extracted AndroidViewClient-master.zip to C drive, after that I installed android viewclient using easy_install When I am running a simple py script with monkeyrunner I am getting the error mismatched input 'as' expecting CLONE in dtmilano viewclient.py
My code look like this:
! /usr/bin/env monkeyrunner
import re
import sys
import os
import java
import glob
import os
sys.path.append('C:\AndroidViewClient-master\src')
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.dtmilano.android.viewclient import ViewClient
try:
ANDROID_VIEW_CLIENT_HOME = os.environ['ANDROID_VIEW_CLIENT_HOME']
except KeyError:
print >>sys.stderr, "%s: ERROR: ANDROID_VIEW_CLIENT_HOME not set in environment" % __file__
sys.exit(1)
device= MonkeyRunner.waitForConnection(15)
mydir=r'C:\Android SDK\adt-bundle-windows\sdk\tools'
apk_path = device.shell('pm path com.sample.test')
if apk_path.startswith('package:'):
print "Test app is already installed."
else:
print "Test app is not installed, installing..."
os.chdir(mydir)
MonkeyRunner.sleep(1)
app = "Test.apk"
device.installPackage(mydir+"/"+app)
MonkeyRunner.sleep(5)
print "Launching Resource Test app"
device.startActivity(component='com.sample.test/com.sample.test.MainActivity')
MonkeyRunner.sleep(5)
My path variable is:
C:\Android SDK\adt-bundle-windows\sdk\tools;C:\Python27;C:\Python27\Scripts
Please tell me whats wrong here? Do I need to install a different version of python.
This the error I am getting:
C:\Users\Desktop>monkeyrunner test1.py
150520 11:10:35.203:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
150520 11:10:35.203:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "C:\Android SDK\adt-bundle-windows\sdk\tools\test1.py", line 12, in <module>
from com.dtmilano.android.viewclient import ViewClient
SyntaxError: ("mismatched input 'as' expecting COLON", ('C:\\AndroidViewClient-master\\src\\com\\dtmilano\\android\\viewclient.py', 3708, 35, ''))
C:\Users\Desktop>
And the line 12 in test1.py is:
from com.dtmilano.android.viewclient import ViewClient
Line 3708 is viewclient.py is:
except ImportError as ex:
Please help.