Cannot run monkeyrunner scripts (for example, two monkeyrunner processes) at the same time on multiple devices

test.py script content:

import ....

device = MonkeyRunner.waitForConnection(10,sys.argv[1])

device.startActivity(component='package/activity')

'''
some monkeyrunner events
'''

I have two devices: labled device1-id and device2-id

  • run test.py on monkeyrunner1-id &

  • run test.py on monkeyrunner2-id &

I found that some events in device2 were sent to device1. I do not know why?

I noticed some tutorials, they said that if you run monkeyrunner on other devices, you can write a script as shown below:

device1 = MonkeyRunner.waitForConnection(10,device1-id)
device2 = MonkeyRunner.waitForConnection(10,device2-id)

device1.actions

device2.actions

but that was not what I needed. Does anyone know why a monkey behaves like this?

I need to have one script at the same time run the same script on multiple devices.

+2
2

, Monkeyrunner .

, 2 , hardcoding deviceId . script: "start script1", "start script2" Unix "script1 &; script2 &"

: 1 , , . SCript2 , , .

+1

, ,

 # Imports the monkeyrunner modules used by this program
 from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
 import sys

 # Connects to the current device, returning a MonkeyDevice object
 device = MonkeyRunner.waitForConnection(timeOut,"emulator-"+ sys.argv[1])

 MONKEYRunner Actions . . . . 

: sys.arv [0]

, :

   monkeyrunner test.py PortNumber  
+3

All Articles