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(JavaScriptEngine.java:256) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:698) at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(HtmlScript.java:187) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(HTMLParser.java:418) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:379) 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:2831) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809) 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:312) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226) 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:431) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:362) at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickAction(HtmlAnchor.java:115) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:114) at net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.clickLinkWithExactText(HtmlUnitDialog.java:1412) at net.sourceforge.jwebunit.junit.WebTester.clickLinkWithExactText(WebTester.java:1853) at net.sourceforge.jwebunit.junit.WebTestCase.clickLinkWithExactText(WebTestCase.java:1431) at com.jwebtest.test.Project.testsearch(Project.java:26) 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(WebTestCase.java:47) at com.jwebtest.test.Project.main(Project.java:72)
Can any body help me.Normal execution through browser is perfect.Thanks in advance.
Anil
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
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.
I have used HttpUnitOptions.setExceptionsThrownOnScriptError( false ); to ignore the exception but it is not working.
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
5
posted
0
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.