Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Monkeyrunner script on multiple devices at the same time

I am trying to run a monkeyrunner script on multiple devices to do some basic operations.I figured out that initialy I will start of writing a script to perform basic action in two connected devices.

  from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

  import time

   import sys


    import time


   devices = os.popen('adb devices').read().strip().split('\n')[1:]

 device1 = MonkeyRunner.waitForConnection( devices[0].split('\t')[0])  
  package = 'com.android.browser'

  activity = 'com.android.browser.BrowserActivity'
  runComponent = package + '/' + activity
 device1.startActivity(component=runComponent)

  MonkeyRunner.sleep(1)

 device2 = MonkeyRunner.waitForConnection( devices[1].split('\t')[0])  
  package = 'com.android.browser'

 activity = 'com.android.browser.BrowserActivity'
 runComponent = package + '/' + activity
  device2.startActivity(component=runComponent)

When i run this script, it never finish executing. The browser action happen on one of the connected device but not on other. Can you guys help me fix this or if you have a better code(ideas) to run an activity on multiple devices, Please do let me know~ I am newbie and completely new to the programming world!Thanks in advance

like image 453
Elsa Adams Avatar asked Nov 05 '22 04:11

Elsa Adams


1 Answers

you can give like

device1 = MonkeyRunner.waitForConnection('', devices[0].split('\t')[0]) 

this will help

like image 117
Rilwan Avatar answered Nov 07 '22 20:11

Rilwan