【问题标题】:Calabash for Cordova Android app on AWS Device Farm, correct webview name?AWS Device Farm 上用于 Cordova Android 应用程序的 Calabash,正确的 webview 名称?
【发布时间】:2016-01-02 16:55:47
【问题描述】:

我在尝试为 Cordova 应用程序编写 Calabash 测试时遇到了麻烦。 webView 和 cordovaWebView 在本地或 AWS 上对我不起作用。


当我在设备上运行时在本地运行的代码变体:

Then(/^I entered text "(.*?)" into input with id "(.*?)"$/) do |arg1, arg2|
    enter_text("SystemWebView css:'##{arg2}'", arg1)
end

但是,在 AWS 上它给了我这个错误:

map SystemWebView css:'#login-email',查询失败,因为:java.util.concurrent.ExecutionException: java.lang.ClassCastException: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient 无法转换为 org.apache .cordova.engine.SystemWebChromeClient (运行时错误) (运行时错误) ./features/step_definitions/calabash_steps.rb:8:in /^I entered text "(.*?)" into input with id "(.*?)"$/' features/login.feature:7:in然后我将文本“test@tester”输入到ID为“login-email”的输入中


我尝试了另一个代码变体,希望它可以在 AWS Device Farm 上运行:

Then(/^I entered text "(.*?)" into input with id "(.*?)"$/) do |arg1, arg2|
    enter_text("CalabashChromeClient css:'##{arg2}'", arg1)
end

但这也给了我一个错误: 等待元素超时:CalabashChromeClient css:'#login-email' (Calabash::Android::WaitHelpers::WaitError)


使用cordovaWebView,我收到以下错误:

等待元素超时:cordovaWebView css:'#login-email' (Calabash::Android::WaitHelpers::WaitError)


我通过在控制台中玩耍找到了在本地运行的正确 webview 名称。谈到 AWS Device Farm,我在这里有点盲目,希望你们能提供的所有提示/技巧。我也愿意切换测试框架。


 query("*")
[
    [0] {
                        "id" => nil,
                   "enabled" => true,
        "contentDescription" => nil,
                   "visible" => true,
                       "tag" => nil,
               "description" => "com.android.internal.policy.impl.PhoneWindow$DecorView{41c4f3b8 V.E..... R.....I. 0,0-720,1232}",
                     "class" => "com.android.internal.policy.impl.PhoneWindow$DecorView",
                      "rect" => {
            "center_y" => 616,
            "center_x" => 360,
              "height" => 1232,
                   "y" => 0,
               "width" => 720,
                   "x" => 0
        }
    },
    [1] {
                        "id" => nil,
                   "enabled" => true,
        "contentDescription" => nil,
                   "visible" => true,
                       "tag" => nil,
               "description" => "android.widget.LinearLayout{41c4f8a8 V.E..... ......I. 0,0-720,1232}",
                     "class" => "android.widget.LinearLayout",
                      "rect" => {
            "center_y" => 616,
            "center_x" => 360,
              "height" => 1232,
                   "y" => 0,
               "width" => 720,
                   "x" => 0
        }
    },
    [2] {
                        "id" => "content",
                   "enabled" => true,
        "contentDescription" => nil,
                   "visible" => true,
                       "tag" => nil,
               "description" => "android.widget.FrameLayout{41c50560 V.E..... ......I. 0,25-720,1232 #1020002 android:id/content}",
                     "class" => "android.widget.FrameLayout",
                      "rect" => {
            "center_y" => 628,
            "center_x" => 360,
              "height" => 1207,
                   "y" => 25,
               "width" => 720,
                   "x" => 0
        }
    },
    [3] {
                        "id" => nil,
                   "enabled" => true,
        "contentDescription" => nil,
                   "visible" => true,
                       "tag" => nil,
               "description" => "android.widget.ImageView{41bb9f40 V.ED.... ........ 0,0-720,1207}",
                     "class" => "android.widget.ImageView",
                      "rect" => {
            "center_y" => 628,
            "center_x" => 360,
              "height" => 1207,
                   "y" => 25,
               "width" => 720,
                   "x" => 0
        }
    }
]

【问题讨论】:

    标签: android cordova amazon-web-services webview aws-device-farm


    【解决方案1】:

    这个问题似乎与新的 Android 系统 WebViews 有关。例如,您使用的是 Android 5.1 或更高版本吗? 与 webView 相同的应用程序在 4.4 智能手机上运行良好,但由于此错误而在某些 5.1 上失败。

    阅读其他帖子后,我发现这应该在 Calabash-Android 的 0.5.12 版本中得到修复。

    查看更改日志: calabash-android 0.5.12 的发行说明 修复了对 Lollipop 和 M 中的新 Android 系统 WebView 不起作用的 Calabash WebView 查询。

    请更新!!!

    【讨论】:

    • 我相信,我在 4.0 - 5.1 的 android 版本中测试了 100 台设备,无论是否使用 Crosswalk。自从我上次接触这个项目以来已经有很长时间了,但我会在有时间的时候尝试一下(这些天我已经非常喜欢 React/Node.js 和 ES6/ES7 了!)。
    【解决方案2】:

    您的应用是常规应用还是 Cordova 应用?

    您应该能够使用 webView 或 cordovaWebView 查询 webview

    query("webView css:'#header'")
             OR
    query("cordovaWebView css:'#header'")
    

    【讨论】:

    • 这似乎对我在 AWS 或本地不起作用。我在 AWS 上等待元素超时:cordovaWebView css:'#login-email' (Calabash::Android::WaitHelpers::WaitError)。在本地,它仅适用于 SystemWebView。我编辑了我的问题以包含我在本地运行 query("*") 时看到的内容。
    【解决方案3】:

    来自 AWS 支持:“他们已经能够重现您的问题,并且正在进一步调查。现在,我可以告诉您这目前不起作用,可能是我们必须推动功能请求以添加功能。如果是这种情况,他们可能需要一些时间来实现功能。 -- 2015 年 10 月 22 日

    【讨论】:

      【解决方案4】:

      您在使用 CrossWalk 吗?如果是这种情况,那么这应该可以工作:

      query("org.crosswalk.engine.XWalkCordovaView css:'.page-on-center#intro'")

      但是,它无法在 AWS Device Farm 上运行。得到以下错误:

      ',查询失败,因为:java.util.concurrent.ExecutionException: java.lang.RuntimeException: sh.calaba.org.codehaus.jackson.map.JsonMappingException:不能 从 START_ARRAY 令牌中反序列化 java.util.HashMap 的实例

      【讨论】:

      • 我有人行横道,但最终将其移除。它太笨重了,在很多较弱的设备上都会崩溃。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多