3

I'm running into trouble trying to write Calabash tests for a Cordova application. webView and cordovaWebView do not work for me locally or on AWS.


Code variation that does work locally when I run against a device:

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

However, on AWS it gives me this error:

map SystemWebView css:'#login-email', query failed because: java.util.concurrent.ExecutionException: java.lang.ClassCastException: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient cannot be cast to 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:inThen I entered text "test@tester" into input with id "login-email"'


Another code variation I tried, hoping it would work on AWS Device Farm:

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

But that too gives me an error: Timeout waiting for elements: CalabashChromeClient css:'#login-email' (Calabash::Android::WaitHelpers::WaitError)


With cordovaWebView, I get the following error:

Timeout waiting for elements: cordovaWebView css:'#login-email' (Calabash::Android::WaitHelpers::WaitError)


I figured out the correct webview name to run locally by playing around in the console. When it comes to AWS Device Farm, I'm a little blind here and would appreciate all hints/tips you guys can offer. I'm also open to switching test frameworks.


 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
        }
    }
]
cat3045
  • 295
  • 2
  • 11

4 Answers4

1

It seems that this issue relates to new Android System WebViews. Are you using Android 5.1 or Higher for exemple? Same app with webView works fine for me on 4.4 smartphone but fails on some 5.1 due to this error.

Reading on other post I found that this should be fixed in 0.5.12 release of Calabash-Android.

See change log: Release notes for calabash-android 0.5.12 Fix Calabash WebView queries not working for new Android System WebViews in Lollipop and M.

Please update!!!

  • I was testing 100 devices across android versions 4.0 - 5.1 with and without Crosswalk, I believe. It's been a long time since I last touched this project, but I'll give it a try when I get a moment (I've been enjoying React/Node.js with ES6/ES7 too much these days!). – cat3045 Dec 12 '15 at 19:28
0

Is your app a regular or Cordova app?

You should be able to query the webview using either webView or cordovaWebView

query("webView css:'#header'")
         OR
query("cordovaWebView css:'#header'")
greg_diesel
  • 2,955
  • 1
  • 15
  • 24
  • That doesn't seem to work for me on AWS or locally. I'm getting Timeout waiting for elements: cordovaWebView css:'#login-email' (Calabash::Android::WaitHelpers::WaitError) on AWS. Locally, it only works with SystemWebView. I edited my question to include what I see when I run query("*") locally. – cat3045 Oct 05 '15 at 23:41
0

From AWS support: "They've been able to reproduce your issue and are looking into this further. For now, I can tell you this doesn't work currently and may be something we have to push into a feature request to add the functionality. If that is the case, it may take some time for them to implement the functionality." -- Oct 22, 2015

cat3045
  • 295
  • 2
  • 11
0

Are you using CrossWalk? If this is the case, then this should work:

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

Havn't been able to get it to work on AWS Device Farm however. Get the following error:

', query failed because: java.util.concurrent.ExecutionException: java.lang.RuntimeException: sh.calaba.org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token

jeroen.verhoest
  • 5,173
  • 2
  • 27
  • 27
  • I had crosswalk, but ended up removing it. It was too bulky and crashing on a lot of weaker devices. – cat3045 Dec 12 '15 at 19:13