【问题标题】:UIAutomator - setText in editText not workUIAutomator - editText 中的 setText 不起作用
【发布时间】: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


    【解决方案1】:

    Flutter 应用程序不适用于 UiAutomator。现在对它们运行集成测试的唯一方法是使用 Flutter 自己的测试实用程序。您可以阅读有关开始使用它的信息here

    【讨论】:

    • 谢谢你这么配!
    猜你喜欢
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多