Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UiAutomator Android-setText方法不起作用。!_Android_Settext_Android Uiautomator - Fatal编程技术网

UiAutomator Android-setText方法不起作用。!

UiAutomator Android-setText方法不起作用。!,android,settext,android-uiautomator,Android,Settext,Android Uiautomator,现在,我正在尝试使用UIAutomator。我们创建一个应用程序。测试时,UIAutomator的setText方法不起作用。单击编辑文本时,显示键盘。然后将文本设置为此对象,但它不起作用 这是我的EditText代码 <EditText android:id="@+id/category_editText" style="@style/Brown.textBox" android:layout_width="match_parent"

现在,我正在尝试使用UIAutomator。我们创建一个应用程序。测试时,UIAutomator的setText方法不起作用。单击编辑文本时,显示键盘。然后将文本设置为此对象,但它不起作用

这是我的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" />


有人能帮我吗?谢谢。

是否使用UIAutomator检查此字段的节点属性?编辑文本的可单击属性应设置为true。如果为false,则可能发生此问题。我建议您检查属性并进行适当的更改,以使clickable属性为true。

我遇到了同样的问题。我使用了
legacySetText
而不是
setText
,它起了作用

在我看来,这段代码不像UiAutomator。这似乎更像是某种相似事物的表现。请在这里查看如何使用该工具的示例:是的,此代码用于我的应用程序中的EditText。我用下面的代码测试这个编辑文本<代码>UiObject文本字段=新UiObject(新UiSelector().description(“category_editText”);textField.setText(“测试”)但它不起作用。问题可能是您试图将文本设置为错误的视图。最简单的解决方案是了解布局的层次视图结构并传递适当的对象。不,我得到了正确的对象。但这不行。当我将光标设置为文本字段时,光标显示,键盘显示。当调用setText方法时,它不起作用。谢谢,但现在,我不这样做。当我再次这样做时,我会回复你的答案。谢谢,我会稍后再试,如果我的代码没有问题,我会接受你的答案。