Android – Mismatched input ‘result expecting RPAREN: While running jython script

androidjythonmonkeyrunnertesting

I have been trying to run a jython script which installs a package and opens a activity and then takes its screen shot and finally saves it in a File. I am using the following Code to do this:

    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
device.installPackage('F:\jind\Example.apk')
package= 'com.android.example'
activity= 'com.android.example.main_activity'
runComponent= package + '/' + activity
device.startActivity(component=runComponent)
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)
result=device.takeSnapshot()
result.writeToFile('F:\jind\lk.png','png')

After running the script. writeToFile() is giving Error saying 'mismatched input 'result' expecting RPAREN

Thanks in Advance

Best Answer

The RPAREN error is due to parameter error in result.writeToFile('F:\jind\lk.png','png'). Its because of escape character. use result.writeToFile('F:\\jind\\lk.png','png') instead to escape '\'. Hope it will work.

Related Topic