RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

NullPointerException when using the searchFor() function on a page that contains a WebView. #700

Closed renas closed 9 years ago

renas commented 9 years ago

From dweep.s...@fixmo.com on July 07, 2014 14:44:51

What steps will reproduce the problem? I am automating test cases on an Android device using calabash-android that uses the Searcher class in this framework. The searchFor function returns a NullPointerException on pages that contain WebViews.

The element in question: { "id" => "url", "enabled" => true, "contentDescription" => nil, "class" => "com.fixmo.browser.UrlInputView", "text" => "www.google.com/webhp?client=ms-android-google&source=android-home", "rect" => { "center_y" => 153.0, "center_x" => 582.0, "height" => 156, "y" => 75, "width" => 660, "x" => 252 }, "description" => "com.fixmo.browser.UrlInputView{43ed0400 VFED..CL ........ 252,0-912,156 #7f0e00a0 app:id/url}" }

adb logcat output: 07-07 17:29:53.459 I/System.out(21864): URI: // 07-07 17:29:53.459 I/System.out(21864): params: {json={"command":"asserttext","arguments":["google",true]} 07-07 17:29:53.459 I/System.out(21864): } 07-07 17:29:53.459 I/System.out(21864): header: {date=Mon, 07 Jul 2014 21:29:53 GMT, accept=/_, content-length=53, host=127.0.0.1:34782, user-agent=HTTPClient/1.0 (2.3.4.1, ruby 1.9.3 (2014-02-24)), content-type=application/json;charset=utf-8} 07-07 17:29:53.459 I/System.out(21864): params: {json={"command":"assert_text","arguments":["google",true]} 07-07 17:29:53.459 I/System.out(21864): } 07-07 17:29:53.459 I/System.out(21864): ProP json = {"command":"assert_text","arguments":["google",true]} 07-07 17:29:53.459 I/System.out(21864): files: {} 07-07 17:29:53.459 I/System.out(21864): command: {"command":"assert_text","arguments":["google",true]} 07-07 17:29:53.459 I/InstrumentationBackend(21864): Got command:'Command:'Line:null,assert_text', arguments:'[google, true]' 07-07 17:29:53.779 E/MP-Decision( 1941): num online cores: 2 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 13 07-07 17:29:53.779 E/MP-Decision( 1941): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:196.000000 07-07 17:29:54.650 W/System.err(21864): java.lang.RuntimeException: java.lang.NullPointerException: lock == null 07-07 17:29:54.650 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:128) 07-07 17:29:54.650 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher.searchWithTimeoutFor(Searcher.java:77) 07-07 17:29:54.650 W/System.err(21864): at com.jayway.android.robotium.solo.Solo.searchText(Solo.java:555) 07-07 17:29:54.650 W/System.err(21864): at sh.calaba.instrumentationbackend.actions.text.AssertText.execute(AssertText.java:14) 07-07 17:29:54.650 W/System.err(21864): at sh.calaba.instrumentationbackend.Command.execute(Command.java:47) 07-07 17:29:54.650 W/System.err(21864): at sh.calaba.instrumentationbackend.actions.HttpServer.runCommand(HttpServer.java:243) 07-07 17:29:54.650 W/System.err(21864): at sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:200) 07-07 17:29:54.650 W/System.err(21864): at sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:454) 07-07 17:29:54.650 W/System.err(21864): at java.lang.Thread.run(Thread.java:841) 07-07 17:29:54.650 W/System.err(21864): Caused by: java.lang.NullPointerException: lock == null 07-07 17:29:54.650 W/System.err(21864): at java.io.Reader.(Reader.java:64) 07-07 17:29:54.650 W/System.err(21864): at java.io.InputStreamReader.(InputStreamReader.java:122) 07-07 17:29:54.650 W/System.err(21864): at java.io.InputStreamReader.(InputStreamReader.java:59) 07-07 17:29:54.650 W/System.err(21864): at com.jayway.android.robotium.solo.WebUtils.getJavaScriptAsString(WebUtils.java:315) 07-07 17:29:54.650 W/System.err(21864): at com.jayway.android.robotium.solo.WebUtils.prepareForStartOfJavascriptExecution(WebUtils.java:142) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.WebUtils.executeJavaScriptFunction(WebUtils.java:248) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.WebUtils.getTextViewsFromWebView(WebUtils.java:57) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher$1.call(Searcher.java:119) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher$1.call(Searcher.java:107) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:204) 07-07 17:29:54.660 W/System.err(21864): at com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:126) 07-07 17:29:54.660 W/System.err(21864): ... 8 more 07-07 17:29:54.680 I/System.out(21864): result:{"bonusInformation":["Exception stack trace:\njava.lang.RuntimeException: java.lang.NullPointerException: lock == null\n\tat com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:128)\n\tat com.jayway.android.robotium.solo.Searcher.searchWit hTimeoutFor(Searcher.java:77)\n\tat com.jayway.android.robotium.solo.Solo.searchText(Solo.java:555)\n\tat sh.calaba.instrumentationbackend.actions.text.AssertText.execute(AssertText.java:14)\n\tat sh.calaba.instrumentationbackend.Command.execute(Command.java:47)\n\tat sh.calaba.instrumentationbacken d.actions.HttpServer.runCommand(HttpServer.java:243)\n\tat sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:200)\n\tat sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:454)\n\tat java.lang.Thread.run(Thread.java:841)\nCaused by: java.lang.Nul lPointerException: lock == null\n\tat java.io.Reader.(Reader.java:64)\n\tat java.io.InputStreamReader.(InputStreamReader.java:122)\n\tat java.io.InputStreamReader.(InputStreamReader.java:59)\n\tat com.jayway.android.robotium.solo.WebUtils.getJavaScriptAsString(WebUtils.java:315)\n\ tat com.jayway.android.robotium.solo.WebUtils.prepareForStartOfJavascriptExecution(WebUtils.java:142)\n\tat com.jayway.android.robotium.solo.WebUtils.executeJavaScriptFunction(WebUtils.java:248)\n\tat com.jayway.android.robotium.solo.WebUtils.getTextViewsFromWebView(WebUtils.java:57)\n\tat com.jaywa y.android.robotium.solo.Searcher$1.call(Searcher.java:119)\n\tat com.jayway.android.robotium.solo.Searcher$1.call(Searcher.java:107)\n\tat com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:204)\n\tat com.jayway.android.robotium.solo.Searcher.searchFor(Searcher.java:126)\n\t... 8 more \n"],"message":"java.lang.NullPointerException: lock == null","success":false} What version of the product are you using? On what operating system? Here is some information about my setup: Device - Samsung Galaxy S4 Device OS - Android 4.3 Calabas...

Original issue: http://code.google.com/p/robotium/issues/detail?id=621

renas commented 9 years ago

From renasr...@gmail.com on July 10, 2014 21:01:15

This happens in an older version of Robotium. Please use the latest 5.2.1.

Status: Invalid
Owner: renasr...@gmail.com

renas commented 9 years ago

From dweep.s...@fixmo.com on July 24, 2014 10:28:37

Thanks for the info, this method is being implemented in a different library, so I think I will have to notify them to fix this problem.