I have written a script in robotium which works just fine, but our application is designed in such a way that it has to interact with the Native android application which cannot be resigned. I have to click a button on the native app which cant be done through robotium. So i wanted to know if i can add a command of monkey runner in my script to click on the app.
问问题
750 次
1 回答
0
solo.sendKey(20); // used for move to next object on screen //
当您专注于所需的按钮时执行上述行并停止
然后执行下面的行,点击按钮
solo.sendKey(66); // Click On Focused Button //
例如,您在屏幕上有 3 个对象:
[1] 用户名 [ 文本框 ]
[2] 密码[文本框]
[3] 提交 [ 按钮 ]
如果您想使用“robotium”点击“提交”按钮,那么
solo.sendKey(20);// focus on username textbox
solo.sendKey(20);// focus on password textbox
solo.sendKey(20);// focus on Submit button
solo.sendKey(66);// Click On Submit Button
通常我们从 munkey 代码发送 keyevents,所以我建议你使用上面的代码。
笔记:
KEYCODE_DPAD_DOWN [常数值:20 (0x00000014)]
KEYCODE_ENTER [常数值:66(0x00000042)]
粘贴自http://developer.android.com/reference/android/view/KeyEvent.html
我在我的自动化应用程序上对此进行了测试。
我希望这会对你有所帮助,谢谢。
于 2012-10-05T13:24:20.897 回答