Hello together,

I just subscribed to the mailing list, my first one ever.

I've got a problem concerning a very small testapp written by me. It was
derived from a larger testframework developed by a colleague of mine. The
Exception is the same...

The simple HTML source with the javascript snipplet:

<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html;
charset=windows-1252"/>
       <meta http-equiv="Content-Language" content="de"/>
       <title> test </title>
   </head>
   <body>
       <script type="text/javascript">
           var nv = navigator;
           var n = nv.userAgent.toLowerCase();
           alert(n);
       </script>
   </body>
</html>

The java source:

package test;

import net.sourceforge.jwebunit.junit.WebTestCase;
import net.sourceforge.jwebunit.junit.WebTester;

public class Test_JavaScript extends WebTestCase {

   private WebTester webTester;
   private static String baseUrl = "url";        //replaced by me
   private static String beginAt = "/startAt";        //replaced by me

   public void setUp() throws Exception{
       this.webTester = getTester();
   }

   public void testJavaScript() {
       getTestContext().setBaseUrl(baseUrl);
       getTestContext().addRequestHeader("Accept-Language", "de,de;q=0.7");
       getTestContext().addRequestHeader("User-Agent", "Mozilla/5.0
(Windows; U; Windows NT 5.1; de; rv:1.8.1.3) Gecko/20070309
Firefox/2.0.0.3");
       beginAt(beginAt);
   }

   public void tearDown() {
       closeBrowser();
   }

}

and here the Exception by the eclipse junit testrunner:

.log4j:WARN No appenders could be found for logger (
com.gargoylesoftware.htmlunit.WebClient).
log4j:WARN Please initialize the log4j system properly.
E
Time: 1.371
There was 1 error:
1) testJavaScript(test.Test_JavaScript)======= EXCEPTION START ========
EcmaError: lineNumber=[2] column=[0] lineSource=[            var n =
nv.userAgent.toLowerCase();] name=[TypeError] sourceName=[Embedded script in
URL from (8, 34) to (0, 0)] message=[TypeError: Cannot call method
"toLowerCase" of null (Embedded script in URL from (8, 34) to (0, 0)#2)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method
"toLowerCase" of null (Embedded script in URL from (8, 34) to (0, 0)#2)
   at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(
JavaScriptEngine.java:260)
   at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(
HtmlPage.java:697)
   at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(
HtmlScript.java:188)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters
(HTMLParser.java:455)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(
HTMLParser.java:415)
   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
   at org.cyberneko.html.filters.DefaultFilter.endElement(
DefaultFilter.java:249)
   at org.cyberneko.html.filters.NamespaceBinder.endElement(
NamespaceBinder.java:367)
   at org.cyberneko.html.HTMLTagBalancer.callEndElement(
HTMLTagBalancer.java:1015)
   at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java
:888)
   at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java
:2841)
   at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:819)
   at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java
:478)
   at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java
:431)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(
HTMLParser.java:346)
   at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java
:229)
   at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(
DefaultPageCreator.java:112)
   at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(
DefaultPageCreator.java:85)
   at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
WebClient.java:441)
   at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:345)
   at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:399)
   at net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(
HtmlUnitDialog.java:161)
   at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:190)
   at net.sourceforge.jwebunit.junit.WebTestCase.beginAt(WebTestCase.java
:130)
   at test.Test_JavaScript.testJavaScript(Test_JavaScript.java:20)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
   at net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java
:58)
   at test.TestRun.main(TestRun.java:10)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call method
"toLowerCase" of null (Embedded script in URL from (8, 34) to (0, 0)#2)
   at org.mozilla.javascript.ScriptRuntime.constructError(
ScriptRuntime.java:3226)
   at org.mozilla.javascript.ScriptRuntime.constructError(
ScriptRuntime.java:3216)
   at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java
:3232)
   at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java
:3251)
   at org.mozilla.javascript.ScriptRuntime.undefCallError(
ScriptRuntime.java:3270)
   at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(
ScriptRuntime.java:1966)
   at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java
:2931)
   at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
   at org.mozilla.javascript.InterpretedFunction.call(
InterpretedFunction.java:149)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java
:337)
   at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(
HtmlUnitContextFactory.java:151)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java
:2755)
   at org.mozilla.javascript.InterpretedFunction.exec(
InterpretedFunction.java:160)
   at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
   at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(
JavaScriptEngine.java:255)
   ... 42 more
Enclosed exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot call method
"toLowerCase" of null (Embedded script in URL from (8, 34) to (0, 0)#2)
   at org.mozilla.javascript.ScriptRuntime.constructError(
ScriptRuntime.java:3226)
   at org.mozilla.javascript.ScriptRuntime.constructError(
ScriptRuntime.java:3216)
   at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java
:3232)
   at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java
:3251)
   at org.mozilla.javascript.ScriptRuntime.undefCallError(
ScriptRuntime.java:3270)
   at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(
ScriptRuntime.java:1966)
   at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java
:2931)
   at script(Embedded script in URL from (8, 34) to (0, 0):2)
   at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
   at org.mozilla.javascript.InterpretedFunction.call(
InterpretedFunction.java:149)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java
:337)
   at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(
HtmlUnitContextFactory.java:151)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java
:2755)
   at org.mozilla.javascript.InterpretedFunction.exec(
InterpretedFunction.java:160)
   at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
   at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(
JavaScriptEngine.java:255)
   at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(
HtmlPage.java:697)
   at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(
HtmlScript.java:188)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters
(HTMLParser.java:455)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(
HTMLParser.java:415)
   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
   at org.cyberneko.html.filters.DefaultFilter.endElement(
DefaultFilter.java:249)
   at org.cyberneko.html.filters.NamespaceBinder.endElement(
NamespaceBinder.java:367)
   at org.cyberneko.html.HTMLTagBalancer.callEndElement(
HTMLTagBalancer.java:1015)
   at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java
:888)
   at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java
:2841)
   at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:819)
   at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java
:478)
   at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java
:431)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(
HTMLParser.java:346)
   at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java
:229)
   at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(
DefaultPageCreator.java:112)
   at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(
DefaultPageCreator.java:85)
   at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
WebClient.java:441)
   at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:345)
   at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:399)
   at net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(
HtmlUnitDialog.java:161)
   at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:190)
   at net.sourceforge.jwebunit.junit.WebTestCase.beginAt(WebTestCase.java
:130)
   at test.Test_JavaScript.testJavaScript(Test_JavaScript.java:20)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
   at net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java
:58)
   at test.TestRun.main(TestRun.java:10)
== CALLING JAVASCRIPT ==
var nv = navigator;
           var n = nv.userAgent.toLowerCase();
           alert(n);
======= EXCEPTION END ========

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1

In the testframework and the simple example the exception is the same. Thank
you for your efforts.

regards from germany

Kai
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to