我在尝试为 Cordova 应用程序编写 Calabash 测试时遇到了麻烦。webView 和 cordovaWebView 在本地或 AWS 上对我不起作用。
当我针对设备运行时,在本地运行的代码变体:
Then(/^I entered text "(.*?)" into input with id "(.*?)"$/) do |arg1, arg2|
enter_text("SystemWebView css:'##{arg2}'", arg1)
end
但是,在 AWS 上它给了我这个错误:
映射 SystemWebView css:'#login-email',查询失败,因为:java.util.concurrent.ExecutionException:java.lang.ClassCastException:sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient 无法转换为 org.apache.cordova。 engine.SystemWebChromeClient (RuntimeError) (RuntimeError) ./features/step_definitions/calabash_steps.rb:8:in/^I entered text "(.*?)" into input with id "(.*?)"$/'
features/login.feature:7:in
然后我在 id 为“login-email”的输入中输入了文本“test@tester”
我尝试的另一个代码变体,希望它能在 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
}
}
]