【问题标题】:Unable to locate UI Object using UiAutomatorView in android.webkit.WebView class无法在 android.webkit.WebView 类中使用 UiAutomatorView 定位 UI 对象
【发布时间】:2015-07-30 09:22:42
【问题描述】:

我正在做一个小型的 android 自动化任务。我正在编写自动化代码来测试初始设备启动过程(当您从盒子中取出设备并第一次打开时)。 其中一种情况是当我们必须输入 Google 帐户凭据时,其中的电子邮件和密码字段包含在 android.webkit.WebView 类中。我无法使用 UiAutomatorview 访问电子邮件和密码字段。无法访问,因此我无法在这些字段中输入实际输入。此外,由于这只是一种启动设备,因此无法运行任何其他可以帮助我识别 UI 组件的应用程序。

有没有人遇到过类似的问题并能够克服它? 我尝试了以下方法来定位对象但也不返回任何 UI 对象

UiObject2 googleAccName = mUiDevice.findObject(By.text("Enter your email"));

if( googleAccName != null && 
    googleAccName.isEnabled() && 
    googleAccName.isClickable()) {

    googleAccName.click();
    googleAccName.setText("xxxxx@gmail.com");
}
else {
    Log.e(TAG, "No Text field to enter email found !!");
    Assert.fail("failed to setup google account");
}

【问题讨论】:

    标签: android android-layout android-uiautomator


    【解决方案1】:

    UiAutomator 不适用于 Web 视图。如果它是 web 视图(正如您在标题中所说),则无法使用 UiAutomator 来实现。

    【讨论】:

    • 你能推荐一些替代方案吗?我试过 Selendroid,但它需要加载一个应用程序才能开始剖析它的 UI 组件。 (如我的问题中所述)我正在研究初始启动自动化,其中大部分是 Google 设置部分,不能作为 apk 加载。因此,其他一些工作将有很大帮助。提前致谢。
    • 我所知道的唯一一个可以让您处理的不仅仅是被测应用程序是 UiAutomator。我知道的其他人(Selendroid、Espresso、Appium、Robotium)必须与应用程序相关联。所以我真的想不出一个替代方案来帮助你抱歉。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多