【问题标题】:Wait for and click buttons for install and open in Playstore等待并单击按钮以在 Playstore 中安装和打开
【发布时间】:2019-04-12 10:21:49
【问题描述】:

我想通过 Playstore 自动安装和打开一个应用程序。 这是代码:

 // Search for Install Button in Google Play Store and click it
    SearchCondition<UiObject2> isAvailableInstall = Until.findObject(By.textContains(install));
    device.wait(isAvailableInstall, 100000);
    UiObject installButton = device.findObject(new UiSelector()

            .textContains(install));

    if (installButton.exists()) {
        installButton.click();

    }

    // Open App after install

    //TODO: FIX
    device.wait(Until.findObject(By.textContains(open)), 100000);
    UiObject openButton = device.findObject(new UiSelector()

            .textContains(open));

    if (openButton.exists()) {
        openButton.click();

    }

"install" 和 "open" 是带有按钮语言特定名称的字符串(英文为 INSTALL 和 OPEN) 有时,他在设备中找不到打开按钮。等待和超时。为什么?

【问题讨论】:

    标签: android testing android-uiautomator


    【解决方案1】:

    您在这里提出的问题,似乎为安装应用程序设置的时间可能不足以让应用程序安装在设备中。另一种可能性是设备的默认语言可能不是英语。

    我建议您使用resourceID 而不是通过根据内容文本识别按钮来单击按钮。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-17
      • 1970-01-01
      • 2013-06-21
      • 1970-01-01
      • 2019-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多