【发布时间】:2019-01-23 18:43:42
【问题描述】:
我开发了一个 Flutter 聊天。现在我正在尝试使用 UI automator 进行测试,但用于编辑文本的 setText 方法不起作用。 UI Automator Viewer app
这适用于带有 Android Studio 的 Windows 10。
我有一个定义对象的类
public class ChatAppObjects {
public static UiObject ICON_CHATAPP = new UiObject(new UiSelector().className("android.widget.TextView").text("ChatApp"));
public static UiObject TXT_MESSAGE = new UiObject(new UiSelector().className("android.widget.EditText"));
public static UiObject BTN_SEND = new UiObject(new UiSelector().className("android.widget.Button"));
}
这就是测试
public void test1() throws UiObjectNotFoundException, InterruptedException {
UiDevice mDevice = UiDevice.getInstance();
mDevice.pressHome();
ChatAppObjects.ICON_CHATAPP.clickAndWaitForNewWindow();
ChatAppObjects.TXT_MESSAGE.click();
ChatAppObjects.TXT_MESSAGE.clearTextField();
ChatAppObjects.TXT_MESSAGE.setText("Prueba");
ChatAppObjects.BTN_SEND.click();
}
测试运行成功但没有将“Prueba”写入文本框
【问题讨论】:
标签: junit android-edittext flutter settext android-uiautomator