Espresso - typeText not working

前端 未结 10 1112
名媛妹妹
名媛妹妹 2021-02-13 22:20

I\'m trying to type some text inside an EditText:


    public void testSearch() {
          onView(withId(R.id.titleInput)).perform(typeText(\"Engineer\"));
          


        
10条回答
  •  猫巷女王i
    2021-02-13 22:42

    You can bypass the problem by calling setText on the EditText.

       final EditText titleInput = (EditText) activity.findViewById(R.id.titleInput);
       getInstrumentation().runOnMainSync(new Runnable() {
            public void run() {
                titleInput.setText("Engineer");
            }
        });
    

提交回复
热议问题