Android - issue in controlling builtin app using Robotium

孤街醉人 提交于 2019-12-13 06:41:17

问题


I am writing an android testing application which automates testing on the device.

I am targeting facebook as my base application and writing an app using the Robotium framework in order to accomplish my requirement.

Until now i have successfully implemented a few features, but I am stuck at one point: I want to automate the "upload picture" functionality, but as soon as the upload button is clicked, the device builtin application gets activated. I could not control the default app using Robotium.

Is there any way to solve this, by writing some code using robotium or writing a layer between the OS and Robotium which can generate key stokes?


回答1:


I don't think you can do that. However you might be able to make your own modified version of the built-in application and use that instead (if you can make it default and so not have to go through a selection screen), or root a phone and break its security model to use as an automated testing device.




回答2:


You said

a layer between the OS and Robotium.

If you were ok with that, there is the black-box UIAutomator-Framework by google, which might be able to do that. Additionally,

You might want to use monkeyrunner like this:

$ monkeyrunner
>>> from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
>>> device = MonkeyRunner.waitForConnection()
>>> device.touch(200, 400, MonkeyDevice.DOWN_AND_UP)

You can also do a drag, start activies etc. Have a look at the api for MonkeyDevice.

(from this SO answer).



来源:https://stackoverflow.com/questions/4306529/android-issue-in-controlling-builtin-app-using-robotium

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!