I'm trying to write some units tests around a website that use javascript to
build a dynamic menu system for each page.
I have a unit test up and running but it fails when I enable the javascript
support. Our site includes several java script support files to the head of
the page. It looks like "element" may not be supported by httpunit.
If necessary, I can zip up a static page with the *.js files and send it for
easier troubleshooting. Or I can add a snippet
1) Should I stay with the troubleshooting the javascript support? If this
its not too major, I could add the support for "element" in httpunit.
2) Or should I just disable javascript, and then manually search for the
link in the response var tag. I would like to do the following in our code.
search for "AMS" in the response (need to find a httpunit method)
to get this.
-returns:
"/ims/servlet/Service?OPERATION=display&COLLABORATION=account&TARGET=home
In all of our responses, there is a var SnccMenu_ITEMS that has
every link on our menu system.
Suggestions Anyone!!
Thanks for the Help!
Nick Neuberger
The following error results:
TypeError: "element" is not defined. (httpunit; line 1)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:590)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:550)
at
org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:560)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java(Compiled
Code))
at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:62)
at
org.mozilla.javascript.NativeGlobal.evalSpecial(NativeGlobal.java:531)
at
org.mozilla.javascript.ScriptRuntime.callOrNewSpecial(ScriptRuntime.java:120
9)
at
org.mozilla.javascript.ScriptRuntime.callSpecial(ScriptRuntime.java:1249)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java(Compiled
Code))
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java(Compiled
Code))
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2212)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2212)
at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:62)
at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:55)
at org.mozilla.javascript.Context.evaluateString(Context.java:781)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.executeScript(
JavaScript.java:122)
at
com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDele
gate.java:64)
at
com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter
.java:150)
at
com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131
)
at org.cyberneko.html.HTMLTagBalancer.endElement(Unknown Source)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(Unknown
Source)
at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at
com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:244)
at
com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1014)
at
com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:611)
at
com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaScript.ja
va:424)
at
com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
at
com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(JavaScri
ptEngineFactory.java:46)
at
com.meterware.httpunit.RequestContext.runScripts(RequestContext.java:44)
at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:119)
at com.meterware.httpunit.WebClient.getResponse(WebClient.java:112)
at
com.sncc.http.test.LoginTestCase.testGoodLogin(LoginTestCase.java:87)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:171)
at junit.framework.TestCase.runBare(TestCase.java:145)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:136)
at junit.framework.TestSuite.runTest(TestSuite.java:176)
at junit.framework.TestSuite.run(TestSuite.java:172)
at junit.textui.TestRunner.doRun(TestRunner.java:61)
at junit.textui.TestRunner.run(TestRunner.java:183)
at junit.textui.TestRunner.run(TestRunner.java:169)E.
at com.sncc.common.test.SnccTestCase.runTest(SnccTestCase.java:72)
at com.sncc.common.test.SnccTestCase.runMain(SnccTestCase.java:47)
at com.sncc.http.test.LoginTestCase.main(LoginTestCase.java:23)
..
Time: 7.859
There was 1 error:
1) testGoodLogin(com.sncc.http.test.LoginTestCase)
com.meterware.httpunit.ScriptException: Script 'var SnccMenu_ITEMS = [
["AMS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=account&TARGET=home"],
["BMS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=broker&TARGET=home"],
["CMS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=claim&TARGET=home"],
["CMS (Reengineer)",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=WCclaim&TARGET=home"],
["MCG",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=mcg&TARGET=home",],
["MMS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=policyMember&TARGET=ho
me",],
["TMS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=tpa&TARGET=home"],
["Application Queue",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=application&TARGET=hom
e"],
["Policy Queue",
"/ims/servlet/Service?OPERATION=search&COLLABORATION=policyPayrollPeriod"],
["PDS",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=policyDocumentTemplate
&TARGET=home"],
["Agent",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=agent&TARGET=home"],
["Administration", null,
["Application Audit Rule",
"/ims/servlet/Service?OPERATION=search&COLLABORATION=applicationAuditRule"],
["Treaty", null,
["Treaty",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=treaty&TARGET=home"],
["Layer",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=layer&TARGET=home"],
["Limit Allocation",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=limitAllocation&TARGET
=home"],
],
["State Profile",
"/ims/servlet/Service?OPERATION=retrieve&COLLABORATION=stateProfile"],
["State Types Mgmt", null,
["Risk Type Mgmt",
"/ims/servlet/Service?OPERATION=retrieve&COLLABORATION=riskCharacteristicTyp
e"],
["Tax Rt Type Mgmt",
"/ims/servlet/Service?OPERATION=retrieve&COLLABORATION=stateTaxType"],
["Surchg Type Mgmt",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=stateSurchargeType&TAR
GET=home"],
],
["CCIF Factors",
"/ims/servlet/Service?OPERATION=retrieve&COLLABORATION=trendClaimsCostIndexF
actorEffective"],
],
["IS Administration",
"/ims/servlet/Service?OPERATION=display&COLLABORATION=isAdmin&TARGET=home"],
["System Info", null,
["About",
"javascript:jsOpenDialogWindow('/ims/servlet/Service?OPERATION=display&COLLA
BORATION=systemInfo&TARGET=home', 'SystemInfo',400,200);"],
["View Closed Tickets",
"javascript:jsOpenWindow('http://notes001/snccinet.nsf/agtSeeGWIViewForIMS?O
penAgent', 'ClosedTix',900,600);"],
],
];
new menu(SnccMenu_ITEMS, SnccMenu_POSITION,
SnccMenu_STYLES);
//' failed: TypeError: "element" is not defined.
(httpunit; line 1)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptEx
ception(JavaScript.java:192)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.executeScript(
JavaScript.java:126)
at
com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDele
gate.java:64)
at
com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter
.java:150)
at
com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131
)
at org.cyberneko.html.HTMLTagBalancer.endElement(Unknown Source)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(Unknown
Source)
at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at
com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:244)
at
com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1014)
at
com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:611)
at
com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaScript.ja
va:424)
at
com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
at
com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(JavaScri
ptEngineFactory.java:46)
at
com.meterware.httpunit.RequestContext.runScripts(RequestContext.java:44)
at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:119)
at com.meterware.httpunit.WebClient.getResponse(WebClient.java:112)
at
com.sncc.http.test.LoginTestCase.testGoodLogin(LoginTestCase.java:87)
at com.sncc.common.test.SnccTestCase.runTest(SnccTestCase.java:72)
at com.sncc.common.test.SnccTestCase.runMain(SnccTestCase.java:47)
at com.sncc.http.test.LoginTestCase.main(LoginTestCase.java:23)
Nick Neuberger
Programmer / Analyst
IS Department
Safety National Casualty Corporation
- - - - - -
This e-mail message is intended only for the use of the individual or entity
identified in the alias address of this message and may contain confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution of this e-mail message is strictly prohibited. If you have
received this e-mail message in error, please notify the sender immediately
by reply e-mail and delete this message from your system. Thank you.
|