简体   繁体   English

Android-使用Robotium控制内置应用程序时出现问题

[英]Android - issue in controlling builtin app using Robotium

I am writing an android testing application which automates testing on the device. 我正在编写一个可自动在设备上进行测试的android测试应用程序。

I am targeting facebook as my base application and writing an app using the Robotium framework in order to accomplish my requirement. 我将Facebook作为我的基本应用程序,并使用Robotium框架编写了一个应用程序,以实现我的要求。

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. 我无法使用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? 通过使用robotium编写一些代码或在OS和Robotium之间编写可以产生按键的层来解决这个问题,有什么办法?

You said 你说

a layer between the OS and Robotium. 操作系统和Robotium之间的一层。

If you were ok with that, there is the black-box UIAutomator -Framework by google, which might be able to do that. 如果你确定这一说法,有暗箱UIAutomator -framework由谷歌,这可能是能够做到这一点。 Additionally, 另外,

You might want to use monkeyrunner like this: 您可能要像这样使用Monkeyrunner

 $ 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 . 您还可以进行拖动,启动活动等。看一下MonkeyDevice的api。

(from this SO answer ). (来自此SO答案 )。

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. 但是,您可能可以对内置应用程序进行自己的修改,然后使用该版本(如果可以将其设置为默认版本,因此不必通过选择屏幕),或者使手机启动并破坏其安全模型,用作自动化测试设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM