1

I have a script that should be run on two devices at same time, this two devices are connected to one pc.

How can I run the script on both devices at the same time ?

is there some option like -s "SERIAL_NUMBER" , or something l

Lukap
  • 31,523
  • 64
  • 157
  • 244

2 Answers2

2

try this:-

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import os
devices = os.popen('adb devices').read().strip().split('\n')[1:];
deviceid = devices[0].split('\t')[0];
device = MonkeyRunner.waitForConnection('',deviceid)

hope works.

Rilwan
  • 2,251
  • 2
  • 19
  • 28
0

Adjust your script slightly - add a device-id parameter & use that when creating your MonkeyDevice.

MonkeyRunner#waitForConnection(float, string) can take a timeout and a device identifier to start the script on an specific device.

Jens
  • 16,853
  • 4
  • 55
  • 52
  • ok, but how to read the deviceid, and what should I specify for timeout is 100 seconds okey? – Lukap Nov 17 '11 at 08:45
  • Typically you would call `adb devices` and parse the output to retrieve the device identifiers. We typically let the runner "wait forever" - since it's running in a Jenkins job with a timeout it will be killed after a suitable amount of time anyway. – Jens Nov 17 '11 at 09:17