Reputation: 23493
I am trying to do some automated testing against a complex Android app and I'm wondering if MonkeyRunner is the right tool. I keep seeing that you need to load the activity you want to test, but what if you want to test multiple activities? Say you start with main, and then want to test a search function? Can MonkeyRunner test across multiple activities in a single test?
Upvotes: 0
Views: 870
Reputation: 2301
Below code will work.
import os
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
devices = os.popen('adb devices').read().strip().split('\n')[1:];
deviceid1 = devices[0].split('\t')[0];
deviceid2 = devices[1].split('\t')[0];
dev1 = MonkeyRunner.waitForConnection('',deviceid1)
dev2 = MonkeyRunner.waitForConnection('',deviceid2)
Now you can start Activity on 2 devices by taking dev1
or dev2
.
Upvotes: 0
Reputation: 137362
MonkeyRunner starts from a specific Activity
and continues (by simulating presses) to other activities, if it is possible to move to them by your UI. It doesn't stay on one Activity
.
Take a look at the documentation to see how to move with it.
Upvotes: 1