android - 等待并单击按钮以在 Playstore 中安装和打开

标签 android testing android-uiautomator

我想通过 Play 商店自动安装和打开应用程序。 这是代码:

 // 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) 有时,他在设备中找不到打开按钮。等待和超时。为什么?

最佳答案

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

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

关于android - 等待并单击按钮以在 Playstore 中安装和打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55649503/

相关文章:

iOS - 从发布版本中排除测试文件

java - 如何使带有调度程序(Quartz)的应用程序可手动测试?

java - 如何在appium java中获取android元素的 'resource id'和 'content description'属性值?

带有 AndroidAnnotations 的 Android Studio -> 这些类型将不会进行注释处理

javascript - 在 if 语句中测试 redux-saga 并使用真实值

安卓工作室 : Creating a normal xml file in assests folder?

android - UiAutomator的同步

appium - 使用UIAutomatorviewer在Appium中测试Android应用程序时出错

android - 我发布了一个应用程序,一旦对其进行审核,评论就会在几秒钟内消失。发生了什么事,我该如何解决?

android - 如何从服务类中更改墙纸?