GWT 1.4 and HtmlUnit 2.1

8 views
Skip to first unread message

megid

unread,
May 26, 2008, 11:44:24 AM5/26/08
to Google Web Toolkit
Hello all,

After some probing (and not finding too much on the forums) I want to
report of my experiences with GWT 1.4 and HtmlUnit 2.1 (currently, it
is May 2008).

First: It works. But only when using some tricks.

1. Set your webclient to behave as Internet Explorer 7. With GWT
1.4.61, it will still print exception stack traces, but it will work
anyway.

2. Owing to the asynchronous nature of GWT, you will have to wait-loop
for all elements. E.g. if you do button.click(), you have to probe in
a loop wether an element of the expected output appears.

3. Point 2 also applies to table cells. Even if you have a HtmlTable,
you may still get null when calling getCell(row,col): In this
situation, you also have to wait-loop.

With this, my thanks to the ever up-to-date HtmlUnit team, and maybe
this tidbit here is useful to someone.

Kind regards,

Kai

Kevin VanDenBreemen

unread,
Jun 11, 2008, 1:22:54 PM6/11/08
to Google Web Toolkit
I'm a noob. Can you elaborate. Re 1, I've got the following
initialization for my WebClient:

webClient = new WebClient(BrowserVerion.INTERNET_EXPLORER_7_0);

Then for javascript though I'm just doing a joinall on the window
ThreadManager. Unfortunately, that method only takes a constant
timeout....

On May 26, 11:44 am, megid <kai.r...@googlemail.com> wrote:
> Hello all,
>
> After some probing (and not finding too much on the forums) I want to
> report of my experiences with GWT 1.4 andHtmlUnit2.1 (currently, it
> is May 2008).
>
> First: It works. But only when using some tricks.
>
> 1. Set your webclient to behave as Internet Explorer 7. With GWT
> 1.4.61, it will still print exception stack traces, but it will work
> anyway.
>
> 2. Owing to the asynchronous nature of GWT, you will have to wait-loop
> for all elements. E.g. if you do button.click(), you have to probe in
> a loop wether an element of the expected output appears.
>
> 3. Point 2 also applies to table cells. Even if you have a HtmlTable,
> you may still get null when calling getCell(row,col): In this
> situation, you also have to wait-loop.
>
> With this, my thanks to the ever up-to-dateHtmlUnitteam, and maybe

David Feid

unread,
Jun 13, 2008, 2:33:29 PM6/13/08
to Google Web Toolkit
I tried to test the GWT Kitchen Sink application in GWT and it
couldn't even run the scripts on it. Look at this!

======= EXCEPTION START ========
EcmaError: lineNumber=[2] column=[0] lineSource=[ function () {]
name=[TypeError] sourceName=[http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js]
message=[TypeError: Cannot read property "__gwt_initHandlers" from
null (http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js#2)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read
property "__gwt_initHandlers" from null (http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js#2)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$HtmlUnitContextAction.run(JavaScriptEngine.java:553)
at org.mozilla.javascript.Context.call(Context.java:499)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:
511)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
468)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:
970)
at
com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:
119)
at java.lang.Thread.run(Thread.java:595)
at com.gargoylesoftware.htmlunit.ThreadManager
$1.run(ThreadManager.java:130)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read
property "__gwt_initHandlers" from null (http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js#2)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3557)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:
3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:
3582)
at
org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:
3595)
at
org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:
1381)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:
3054)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
2484)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:
162)
at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:
401)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:
192)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
3003)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:
160)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
496)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$6.doRun(JavaScriptEngine.java:461)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$HtmlUnitContextAction.run(JavaScriptEngine.java:549)
... 7 more
Enclosed exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property
"__gwt_initHandlers" from null (http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js#2)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3557)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:
3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:
3582)
at
org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:
3595)
at
org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:
1381)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:
3054)
at script.y(http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js:2)
at script.A(http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js:10)
at script(http://localhost/gwt/www/
com.google.gwt.sample.kitchensink.KitchenSink/
com.google.gwt.sample.kitchensink.KitchenSink.nocache.js:12)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
2484)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:
162)
at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:
401)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:
192)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
3003)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:
160)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
496)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$6.doRun(JavaScriptEngine.java:461)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$HtmlUnitContextAction.run(JavaScriptEngine.java:549)
at org.mozilla.javascript.Context.call(Context.java:499)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:
511)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
468)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:
970)
at
com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:
119)
at java.lang.Thread.run(Thread.java:595)
at com.gargoylesoftware.htmlunit.ThreadManager
$1.run(ThreadManager.java:130)
== CALLING JAVASCRIPT ==

function () {
if (/loaded|complete/.test(k.readyState)) {
x();
A();
}
}

On Jun 11, 1:22 pm, Kevin VanDenBreemen <fractalconfus...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages