4

Now, I am trying for using UIAutomator. We create an application. When testing it, setText method of UIAutomator is not working. When click EditText, key board is appeared. And then set text to this object, but it is not worked.

Here my code for EditText,

<EditText android:id="@+id/category_editText"
             style="@style/Brown.textBox"
             android:layout_width="match_parent"
             android:layout_height="33dp"
             android:contentDescription="@string/category_editText"
             android:ems="10"
             android:gravity="center_vertical"
             android:hint="@string/category_entry"
             android:lines="1"
             android:maxLength="50"
             android:paddingLeft="3dp"
             android:paddingRight="3dp"
             android:scrollHorizontally="true"
             android:singleLine="true" />

Anyone, can help me ? Thanks.

R.Katnaan
  • 2,486
  • 4
  • 24
  • 36
  • This code does not look like UiAutomator to me. It seems more like a manifest of something similar. Please take a look here for an example on how to use the tool: http://developer.android.com/tools/testing/testing_ui.html – Gabriel Porumb Dec 17 '14 at 12:02
  • Yes, this code is for EditText in my application. I test this EditText by the following code. `UiObject textField = new UiObject(new UiSelector().description("category_editText")); textField.setText("Test");` But it is does not work. – R.Katnaan Dec 18 '14 at 04:20
  • The problem could be that your trying to set the text in wrong view. The easiest solution could knowing the hierarchy view structure of your layout and pass appropriate object. – Rajesh Jan 08 '15 at 11:10
  • No, i got the right object. But it can't do. When i set cursor to text field, cursor is shown and keyboard is appeared. When call setText method, it is not working. – R.Katnaan Feb 27 '15 at 11:16

2 Answers2

2

I encountered the same issue. I used legacySetText instead of setText and it worked

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
1

Did you check the node properties of this field using UIAutomator? Your edit text's clickable property should be set to true. if it is false this issue can occur. I suggest you check the properties and make appropriate change for making the clickable property to true.

Komal Kale
  • 11
  • 1