简体   繁体   English

使用机器人发送 Enter 密钥进行 Android 测试?

[英]Send Enter Key using robotium for Android testing?

I am using Robotium for android testing.我正在使用 Robotium 进行 android 测试。 I have a feature where if the user types into a edit text field and then presses the enter key he is taken to the next field.我有一个功能,如果用户在编辑文本字段中键入,然后按回车键,他将被带到下一个字段。 Now to test this in Robotium, I am able to insert text into the text field.现在要在 Robotium 中进行测试,我可以在文本字段中插入文本。 But I do not know how to simulate the enter key press in Robotium.但我不知道如何在 Robotium 中模拟回车键。 If anyone has idea on this please let me know.如果有人对此有任何想法,请告诉我。 Also let me know if there are any other better testing methods available other than Robotium?另外让我知道除了 Robotium 之外是否还有其他更好的测试方法? Thank you for your help and time.感谢您的帮助和时间。

public class MyActivityViewTest extends ActivityInstrumentationTestCase2<MyActivityView> {
 private Solo                solo;

 SynchronizationTest(String name) {
     super("com.mypackage", MyActivityView.class);
     setName(name);
 }

 @Override
 protected void setUp() throws Exception {
     solo                                 = new Solo(getInstrumentation(), getActivity());
 }

 @MediumTest
 public void testEnter() throws Exception {
     solo.sendKey(Solo.ENTER);
 }
}

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

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