Cordova changed its webview from org.apache.cordova.CordovaWebView to org.apache.cordova.engine.SystemWebView

1,045 views
Skip to first unread message

Pas

unread,
Jul 29, 2015, 3:41:21 AM7/29/15
to calabash-android
Dear all

If I query with query("*") my current cordova project then I get

"class"=>"com.android.internal.policy.impl.PhoneWindow$DecorView", "rect"=>{"center_y"=>480, "center_x"=>270, "height"=>960, "y"=>0, "width"=>540, "x"=>0}, "tag"=>nil, "description"=>"com.android.internal.policy.impl.PhoneWindow$DecorView{41e52b58 V.E..... R....... 0,0-540,960}"}, {"id"=>nil, "enabled"=>true, "contentDescription"=>nil, "class"=>"android.widget.LinearLayout", "rect"=>{"center_y"=>480, "center_x"=>270, "height"=>960, "y"=>0, "width"=>540, "x"=>0}, "tag"=>nil, "description"=>"android.widget.LinearLayout{41e53418 V.E..... ........ 0,0-540,960}"}, {"id"=>"content", "enabled"=>true, "contentDescription"=>nil, "class"=>"android.widget.FrameLayout", "rect"=>{"center_y"=>499, "center_x"=>270, "height"=>922, "y"=>38, "width"=>540, "x"=>0}, "tag"=>nil, "description"=>"android.widget.FrameLayout{41e59690 V.E..... ........ 0,38-540,960 #1020002 android:id/content}"}, {"id"=>nil, "enabled"=>true, "contentDescription"=>nil, "class"=>"org.apache.cordova.engine.SystemWebView", "rect"=>{"center_y"=>499, "center_x"=>270, "height"=>922, "y"=>38, "width"=>540, "x"=>0}, "tag"=>nil, "description"=>"org.apache.cordova.engine.SystemWebView{41d52650 VFEDH.CL .F...... 0,0-540,922 #64}"}]

This causes me great problems because I can not query the webview anymore. I tried to query the SystemWebView like this

query("SystemWebView css:'*'") but i get the following error.

map SystemWebView css:'*', query failed because: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient cannot be cast to org.apache.cordova.engine.SystemWebChromeClient
       
(RuntimeError)
     
./features/step_definitions/calabash_steps.rb:11:in `/^I am on the main page$/'
      features/my_first.feature:4:in `
Then I am on the main page'

Is there a quick way around this.

Cheers
Pascal


tobias....@xamarin.com

unread,
Jul 29, 2015, 6:30:13 AM7/29/15
to calabash-android, pascalz...@gmail.com, pascalz...@gmail.com
Please run adb logcat and post the full stack trace.

Pas

unread,
Jul 29, 2015, 8:14:49 AM7/29/15
to calabash-android, pascalz...@gmail.com
Here is the full stack track when query("cordovaWebView css:'*'"). I don't get an error for this but always an empty result.
logcat.txt

Pas

unread,
Jul 29, 2015, 8:34:51 AM7/29/15
to calabash-android, pascalz...@gmail.com
This is the answer I received from SO:

"Unless you install the crosswalk plugin, the webview is still a CordovaWebView, systemWebview will return the CordovaWebView if you use it's getCordovaWebView() method"
http://stackoverflow.com/questions/31696314/make-cordova-use-old-cordovawebview-instead-of-systemwebview?noredirect=1#comment51337065_31696314

Doesn't help me too much because I'm not really familiar with the internals of your framework. However maybe it helps you.

tobias....@xamarin.com

unread,
Jul 29, 2015, 2:18:01 PM7/29/15
to calabash-android, pascalz...@gmail.com, pascalz...@gmail.com
That is not an error. Please post the stacktrace from the right query, e.g. query("SystemWebView css:'*'")

Pas

unread,
Jul 29, 2015, 2:32:01 PM7/29/15
to calabash-android, tobias....@xamarin.com
Here is the full stack trace of the error in adb logcat

W/System.err(25131): java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ClassCastException: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient cannot be cast to org.apache.cordova.engine.SystemWebChromeClient
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith.evaluateWithViews(UIQueryASTWith.java:106)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryEvaluator.evaluateQueryForPath(UIQueryEvaluator.java:84)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryEvaluator.evaluateQueryWithOptions(UIQueryEvaluator.java:19)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.Query.executeQuery(Query.java:52)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:307)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:454)
W
/System.err(25131):     at java.lang.Thread.run(Thread.java:838)
W
/System.err(25131): Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient cannot be cast to org.apache.cordova.engine.SystemWebChromeClient
W
/System.err(25131):     at java.util.concurrent.FutureTask.report(FutureTask.java:94)
W
/System.err(25131):     at java.util.concurrent.FutureTask.get(FutureTask.java:174)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith.evaluateWithViews(UIQueryASTWith.java:61)
W
/System.err(25131):     ... 6 more
W
/System.err(25131): Caused by: java.lang.ClassCastException: sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient cannot be cast to org.apache.cordova.engine.SystemWebChromeClient
W
/System.err(25131):     at org.apache.cordova.engine.SystemWebView.setWebChromeClient(SystemWebView.java:76)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient$1.run(CalabashChromeClient.java:104)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryUtils.runOnViewThread(UIQueryUtils.java:276)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.<init>(CalabashChromeClient.java:109)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.prepareWebView(CalabashChromeClient.java:183)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.WebContainer.evaluateAsyncJavaScript(WebContainer.java:63)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.WebContainer.evaluateAsyncJavaScript(WebContainer.java:43)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.actions.webview.QueryHelper.executeAsyncJavascriptInWebContainer(QueryHelper.java:69)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith.evaluateForWebContainer(UIQueryASTWith.java:199)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith.access$100(UIQueryASTWith.java:21)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith$MatchForViews.call(UIQueryASTWith.java:123)
W
/System.err(25131):     at sh.calaba.instrumentationbackend.query.ast.UIQueryASTWith$MatchForViews.call(UIQueryASTWith.java:110)
W
/System.err(25131):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
W
/System.err(25131):     at android.os.Handler.handleCallback(Handler.java:725)
W
/System.err(25131):     at android.os.Handler.dispatchMessage(Handler.java:92)
W
/System.err(25131):     at android.os.Looper.loop(Looper.java:153)
W
/System.err(25131):     at android.app.ActivityThread.main(ActivityThread.java:5299)
W
/System.err(25131):     at java.lang.reflect.Method.invokeNative(Native Method)
W
/System.err(25131):     at java.lang.reflect.Method.invoke(Method.java:511)
W
/System.err(25131):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
W
/System.err(25131):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
W
/System.err(25131):     at dalvik.system.NativeStart.main(Native Method)


Pas

unread,
Jul 30, 2015, 2:19:34 AM7/30/15
to calabash-android, pascalz...@gmail.com
I solved this:

In sh.calaba.instrumentationbackend.sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient line 89 I added another case for isCordovaWebView and build the gem on my own.

boolean isCordovaWebView = superClassEquals(webViewClass, "org.apache.cordova.CordovaWebView")
                || superClassEquals(webViewClass, "org.apache.cordova.engine.SystemWebView");

I don't know if the change made by Cordova has other implications for your testframe work but it is now possible to query the webview with:

query("systemWebView css:'*'")

Cheers
Pascal


Bohdan Petrivskyy

unread,
Mar 8, 2016, 8:52:26 PM3/8/16
to calabash-android, pascalz...@gmail.com
Hi Pascal,

I am working on Apache Cordova team at Microsoft. Our team is interested in understanding your experiences with embedded Cordova web views. Would you be able to fill in this quick contact info survey http://www.instant.ly/s/WGx9L so that we can get in touch with you?

Kind regards,
Bohdan
Reply all
Reply to author
Forward
0 new messages