zzwendy / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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":"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): 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:2
43)
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.jav
a: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.<init>(Reader.java:64)
07-07 17:29:54.650 W/System.err(21864):         at 
java.io.InputStreamReader.<init>(InputStreamReader.java:122)
07-07 17:29:54.650 W/System.err(21864):         at 
java.io.InputStreamReader.<init>(InputStreamReader.java:59)
07-07 17:29:54.650 W/System.err(21864):         at 
com.jayway.android.robotium.solo.WebUtils.getJavaScriptAsString(WebUtils.java:31
5)
07-07 17:29:54.650 W/System.err(21864):         at 
com.jayway.android.robotium.solo.WebUtils.prepareForStartOfJavascriptExecution(W
ebUtils.java:142)
07-07 17:29:54.660 W/System.err(21864):         at 
com.jayway.android.robotium.solo.WebUtils.executeJavaScriptFunction(WebUtils.jav
a: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.jav
a:454)\n\tat java.lang.Thread.run(Thread.java:841)\nCaused by: java.lang.Nul
lPointerException: lock == null\n\tat 
java.io.Reader.<init>(Reader.java:64)\n\tat 
java.io.InputStreamReader.<init>(InputStreamReader.java:122)\n\tat 
java.io.InputStreamReader.<init>(InputStreamReader.java:59)\n\tat 
com.jayway.android.robotium.solo.WebUtils.getJavaScriptAsString(WebUtils.java:31
5)\n\
tat 
com.jayway.android.robotium.solo.WebUtils.prepareForStartOfJavascriptExecution(W
ebUtils.java:142)\n\tat 
com.jayway.android.robotium.solo.WebUtils.executeJavaScriptFunction(WebUtils.jav
a: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
Calabash-Android version - Tested on 0.4.21
Ruby Version - ruby 1.9.3p545 (2014-02-24)
ADB Version - 1.0.31
Operating System - Windows 7 64-bit

Please let me know if you require any additional information. Thanks!

Original issue reported on code.google.com by dweep.s...@fixmo.com on 7 Jul 2014 at 9:44

GoogleCodeExporter commented 9 years ago
This happens in an older version of Robotium. Please use the latest 5.2.1.

Original comment by renasr...@gmail.com on 11 Jul 2014 at 4:01

GoogleCodeExporter commented 9 years ago
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.

Original comment by dweep.s...@fixmo.com on 24 Jul 2014 at 5:28