1

I need to use AndroidViewClient to do some automated testing. In my code, I use dump() of the ViewClient. But I usually meet the following mistake:

RuntimeError: The views are being refreshed too frequently to dump.

It may raise by this:

ERROR: could not get idle state.

dtmilano (the author of Android Application Testing Guide) answered a similar problem in this question. He said there is a uiautomator limitation.

But my API's number is 19, Why there is still a uiautomator limitation? And how can I deal with this problem? How to use waitforidle()?

Cœur
  • 37,241
  • 25
  • 195
  • 267
wuyuanyi
  • 339
  • 1
  • 2
  • 8

1 Answers1

3

It's a UiAutomator limitation.

As I mentioned in the other answer, an alternative is to use system ViewServer as the backend if your device has secure mode disabled or LocalViewServer if your device is in secure mode but you have access to the source code of the application under test.

EDIT

ViewCliet copes with the differences in the aforementioned backends. That is the same script could run unchanged using a different back end.

For example, to force dump to use ViseServer just run

$ dump --force-view-server-use --all

You can do the same in your scripts.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • How can I use ViewServer in my python script? And I need to test lots of apps on Android emulator. I use `viewclient.dump()` by `from com.dtmilano.android.viewclient import ViewClient` and `from com.dtmilano.android.adb.adbclient import AdbClient`. I can't find "ViewServer" in the moudle. I just started learning python and Android auto test, thank you for your help. – wuyuanyi Apr 28 '15 at 05:52
  • I need to write a heuristic algorithm to test apps. I used `$ dump --force-view-server-use --all` to write into file, and then read it. But now I want to use `list_edittext=vc.dump(window=-1)` in my python.py. Do you mean I need call shell script `$ dump --force-view-server-use --all` in my python.py? – wuyuanyi May 01 '15 at 02:39
  • `dump` was just an example. You can do exactly the same `dump` does from your script. Just take a look at `dump` source code or, even better, use `culebra --force-view-server-use` to generate a script that you can later edit. – Diego Torres Milano May 01 '15 at 03:33