开发者

Send Enter Key using robotium for Android testing?

开发者 https://www.devze.com 2023-03-20 19:29 出处:网络
I am using Robotium for android testing. I have a feature where if the user types into a edit text field and then presses the enter key he is taken t开发者_开发知识库o the next field. Now to test this

I am using Robotium for android testing. I have a feature where if the user types into a edit text field and then presses the enter key he is taken t开发者_开发知识库o the next field. Now to test this in Robotium, I am able to insert text into the text field. But I do not know how to simulate the enter key press in 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? 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);
 }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号