Question

I'm recently started to use python with mobile app automation, as i decided to use python, the main instruments that I've found were monkeyrunner and androidviewclient.

But there is the first issue with which i dont know what to do:

package = 'com.mypackage.android'
activity = '.launchActivity'
component = package + "/" + activity

device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(component=component)


time.sleep(3)

vc = ViewClient(device, serialno)
vc.dump()

showMenu = vc.findViewById("id/no_id/8")
showMenu.touch()

as i'm running it in windows cmd - monkeyrunner mypath\test-case1.py i receive an exception:

131213 18:42:32.555:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
131213 18:42:32.555:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
  File "C:\Python27\tests\1.py", line 26, in <module>
    device, serialno = ViewClient.connectToDeviceOrExit()
  File "C:\Program Files (x86)\Android\AndroidViewClient\AndroidViewClient-maste
r\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 1381, in conne
ctToDeviceOrExit
    ViewClient.setAlarm(timeout+5)
  File "C:\Program Files (x86)\Android\AndroidViewClient\AndroidViewClient-maste
r\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 1341, in setAl
arm
    signal.alarm(timeout)
  File "C:\Program Files (x86)\Android\android-sdk\tools\lib\jython-standalone-2
.5.3.jar\Lib\signal.py", line 222, in alarm
NotImplementedError: alarm not implemented on this platform

am I doing something wrong? Please help.

Thank you a lot!

Was it helpful?

Solution

This is how setAlarm looks like

@staticmethod
def setAlarm(timeout):
    osName = platform.system()
    if osName.startswith('Windows'): # alarm is not implemented in Windows
        return
    signal.alarm(timeout)

so, it tries to identify that is Windows and then not invoking signal.alarm() which is not implemented, but for some reason it fails in your case. Try to print the result of osName to see what went wrong.

UPDATE

Now I see, you are using monkeyrunner as the interpreter but AndroidViewClient >= 4.0.0 is 100% pure python, so you should run your scripts using a python 2.x interpreter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top