This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes jwebunit test case throws exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "jwebunit test case throws exception" Watch "jwebunit test case throws exception" New topic

jwebunit test case throws exception

Anil Prasad

Joined: Feb 22, 2006
Posts: 14
Hi All,

I am writing a test case in which when I click a link next page loaded which includes a javascript file.But it throws exception

testsearch(com.jwebtest.test.Project)======= EXCEPTION START ========
EcmaError: lineNumber=[179] column=[0] lineSource=[null] name=[TypeError] sourceName=[http://ebsi-dell-09:81/is-bin/intershop.static/WFS/PrcMindef/-/en_US/jscript/popcalendar.js] message=[TypeError: Cannot read property "style" from null (http://ebsi-dell-09:81/is-bin/intershop.static/WFS/PrcMindef/-/en_US/jscript/popcalendar.js#179)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "style" from null (http://ebsi-dell-09:81/is-bin/intershop.static/WFS/PrcMindef/-/en_US/jscript/popcalendar.js#179)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(
at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.cyberneko.html.filters.DefaultFilter.endElement(
at org.cyberneko.html.filters.NamespaceBinder.endElement(
at org.cyberneko.html.HTMLTagBalancer.callEndElement(
at org.cyberneko.html.HTMLTagBalancer.endElement(
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(
at org.cyberneko.html.HTMLScanner.scanDocument(
at org.cyberneko.html.HTMLConfiguration.parse(
at org.cyberneko.html.HTMLConfiguration.parse(
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
at com.gargoylesoftware.htmlunit.WebClient.getPage(
at com.gargoylesoftware.htmlunit.WebClient.getPage(
at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickAction(
at net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.clickLinkWithExactText(
at net.sourceforge.jwebunit.junit.WebTester.clickLinkWithExactText(
at net.sourceforge.jwebunit.junit.WebTestCase.clickLinkWithExactText(
at com.jwebtest.test.Project.testsearch(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at net.sourceforge.jwebunit.junit.WebTestCase.runBare(
at com.jwebtest.test.Project.main(

Can any body help me.Normal execution through browser is perfect.Thanks in advance.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41034
Make sure that whichever JavaScript/DOM construct/property causes the problem is supported by jWebUnit/HtmlUnit. While basic JS is supported, not all DOM methods are available.

Ping & DNS - my free Android networking tools app
Anil Prasad

Joined: Feb 22, 2006
Posts: 14

I have used HttpUnitOptions.setExceptionsThrownOnScriptError( false );
to ignore the exception but it is not working.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Originally posted by Anil Prasad:
I have used HttpUnitOptions.setExceptionsThrownOnScriptError( false );
to ignore the exception but it is not working.

Where did you call this method? If I remember correctly, you need to call this method before instantiating your web client object.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: jwebunit test case throws exception
Similar Threads
java script issue on httpunit
java script issue on httpunit
Canoo web testing
HttpUnit-Net Connection Error
Help using htmlunit