Hi Troy,

if you really mean HTTPUnit, then you use a really old version of WebTest. We've switched to HtmlUnit for over 2 years to have a better js support.

Concerning htmlunit and your js. You could surely tell your developers that they could write better code: the call to eval doesn't make sense in your example ;-( Nevertheless it seems that eval is available on each node in a browser and this should be the case in htmlunit too. Please open an issue by htmlunit for that.

Marc.

Troy McGuire wrote:
Hello Everyone,

I'm thinking I've found an area where HTTPUnit isn't handling some JavaScript, but I hope I'm wrong. Since I'm not really sure why I'm getting this result, maybe someone out there can verify for me what is happening.

I've created a test that fills out a form that includes radio buttons. There is a text field that should only be enabled if one particular radio button is selected, so some JavaScript handles that. The function called is "document.eval", which the developer assured me is a standard function in JavaScript (not one of our functions). However, the error message I'm getting says that it can't find the function "eval". Below I have included portions of the error message, source, and my test script. If this is HTTPUnit not handling this JavaScript function, is there a way around this (without changing the source) so I can finish the test?

Thanks,

Troy

********************* MY SCRIPT *********************
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "/usr/local/sbin/canoo_webtest/selftests/config/WebTest.dtd" [
   <!ENTITY config SYSTEM "config.xml">
   <!ENTITY login SYSTEM "login.xml">
]>

<project name="Event Tracker - Create Fields" basedir="." default=" :._-=+*****+=-_ Create Fields Test _-=+*****+=-_.">
   <property name="test.file" value="sa_et-create_fields.xml" />
<target name=" :._-=+*****+=-_ Create Fields Test _-=+*****+=-_." description="Verifies that each field type can be created"> <echo message=" `'-=+_____+=-' '-=+_____+=-'` Start execution of '${test.file}' in dir '${test.dir}'"/>
       <webtest name="sa_et-create_fields">
           &config;
           <steps>
               &login;
               <invoke
                   description="Loads Event Tracker's Create Field page"
                   url="eventTracker/addCustomField.php" />
               <verifyText
description="Verifies unique text on Event Tracker's Create Field page" text="Decimal/Float - For real numbers that contain a decimal. (i.e. 458.32)" />
               <selectForm
                   description="Selects the 'Create A Field' Form"
                   name="submissionForm" />
               <setInputField
                   description="Selects and sets the 'Title' Field"
                   value="Script Tiny Text"
                   name="title" />
               <setInputField
                   description="Selects and sets the 'Field Name' Field"
                   value="script_tiny_text"
                   name="field_name" />
               <setInputField
                   description="Selects and sets the 'Description' Field"
value="This is the description field where we'll test various characters like . to name a few."
                   name="description" />
               <setRadioButton
                   description="Selects the 'Tiny Text' radio button"
                   value="Tiny Text"
                   name="data_type" />
               <clickButton
                   description="Clicks the Add button"
                   name="submit" />
               <verifyText
description="Verifies unique text after creating a Tiny Text field" text="You have successfully added a custom field. The field name is script_tiny_text." />
           </steps>
       </webtest>
   </target>
</project>
********************* END: MY SCRIPT *********************

********************* SOURCE *********************

...snip...

...snip...
<table><tr><td>
<script language="JavaScript" type="text/javascript">
        <!--
function pageInit(){} function enableList( name )
            {
                if( name == 'List' )
                {
field = document.eval( "document.submissionForm.enum_list" );
                    field.disabled = "";
                    field.value = "";
                }
                else
                {
field = document.eval( "document.submissionForm.enum_list" );
                    field.disabled = "true";
                    field.value = "";
                }
            }
//--> </script><form action="addCustomField.php" method="post" name="submissionForm" enctype="multipart/form-data"><table align="center" border="0" cellpadding="3" cellspacing="0"> <tr><td colspan="3" align="center" bgcolor="#CECECE" valign="top"><b>Add a Custom Field</b></td></tr>

<tr><td><br></td></tr>
<tr>
<td align="right" nowrap valign="top">
                                Title:
                            </td>
<td align="left" valign="top"><input name="title" value="" size="25" type="text"></td>
</tr>
<tr>
<td align="right" nowrap valign="top">
                                Field Name:
                            </td>
<td align="left" valign="top"><input name="field_name" value="" size="25" type="text"></td>
</tr>
<tr>
<td align="right" nowrap valign="top">

                                Description:
                            </td>
<td align="left" valign="top"><textarea name="description" rows="4" cols="25"></textarea></td>
</tr>
<tr>
<td align="right" nowrap valign="top">
                                Type:
                            </td>
<td align="left" valign="top" nowrap>
<input type="radio" name="data_type" value="Tiny Text" onClick="enableList( 'Tiny Text');">Tiny Text - For text that is 255 characters or less. (i.e. North Dakota)<br><input type="radio" name="data_type" value="Text" onClick="enableList( 'Text');">Text - For large amounts of text. (i.e. Paragraphs of text)<br><input type="radio" name="data_type" value="Tiny Integer" onClick="enableList( 'Tiny Integer');">Tiny Integer - For whole numbers that are 255 or less. (i.e. 23)<br><input type="radio" name="data_type" value="Integer" onClick="enableList( 'Integer');">Integer - For whole numbers that may be larger than 255. (i.e. 32,436)<br><input type="radio" name="data_type" value="Decimal/Float" onClick="enableList( 'Decimal/Float');">Decimal/Float - For real numbers that contain a decimal. (i.e. 458.32)<br><input type="radio" name="data_type" value="True/False" onClick="enableList( 'True/False');">True/False - For fields that have only two options. (i.e. Yes)<br><input type="radio" name="data_type" value="Date" onClick="enableList( 'Date');">Date - For month, day, and year. (i.e. June 16 2006)<br><input type="radio" name="data_type" value="Date and Time" onClick="enableList( 'Date and Time');">Date and Time - For month, day, year, and time. (i.e. June 16 2006 3:24 PM)<br><input type="radio" name="data_type" value="Currency" onClick="enableList( 'Currency');">Currency - For decimal numbers with two digits after the decimal and a dollar sign. (i.e. $4,284.56)<br><input type="radio" name="data_type" value="List" onClick="enableList( 'List');">List - For data that has a limited amount of multiple values. (i.e. Small - from a list of 'Small', 'Medium', and 'Large')<br><ul>

Enter the list of items to select from, separated by commas. <br> Each value must be encapsulated by single quotes.(i.e. 'Blue', 'Red', 'Green', 'Yellow')<br><input type="text" name="enum_list" size="50" disabled>
</ul>
</td>

...snip...

********************* END: SOURCE *********************

********************* ERROR MESSAGE *********************
... snip ...
... snip ...
[setRadioButton] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: setRadioButton "Selects the 'Tiny Text' radio button" (12/14) [setRadioButton] INFO (com.canoo.webtest.steps.form.AbstractSetFieldStep) - Found 1 suitable fields, considering only the first one [setRadioButton] INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1217. [setRadioButton] INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class: com.gargoylesoftware.htmlunit.ScriptException [setRadioButton] INFO (com.canoo.webtest.steps.Step) - Message was: TypeError: Cannot find function eval. (Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php#15) [setRadioButton] ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step SetRadioButton at /usr/local/www/customer.com/qa/canoo_webtest/sa_et-create_fields.xml:39: with (value="Tiny Text", description="Selects the 'Tiny Text' radio button", name="data_type", stepType="setRadioButton")
[setRadioButton] ======= EXCEPTION START ========
[setRadioButton] EcmaError: lineNumber=[15] column=[0] lineSource=[null] name=[TypeError] sourceName=[Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php] message=[TypeError: Cannot find function eval. (Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php#15)] [setRadioButton] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function eval. (Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php#15) [setRadioButton] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:307) [setRadioButton] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:733) [setRadioButton] at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107) [setRadioButton] at com.canoo.webtest.steps.form.SetRadioButton.setField(SetRadioButton.java:52) [setRadioButton] at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractSetFieldStep.java:124) [setRadioButton] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38) [setRadioButton] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [setRadioButton] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [setRadioButton] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.Main.runBuild(Main.java:668) [setRadioButton] at org.apache.tools.ant.Main.startAnt(Main.java:187) [setRadioButton] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [setRadioButton] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [setRadioButton] Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function eval. (Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php#15) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3226) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3216) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3232) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3244) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3304) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:1988) [setRadioButton] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2931) [setRadioButton] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [setRadioButton] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [setRadioButton] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [setRadioButton] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [setRadioButton] at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:87) [setRadioButton] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302)
[setRadioButton]        ... 37 more
[setRadioButton] Enclosed exception:
[setRadioButton] org.mozilla.javascript.EcmaError: TypeError: Cannot find function eval. (Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php#15) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3226) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3216) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3232) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3244) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3304) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:1988) [setRadioButton] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2931) [setRadioButton] at script.enableList(Embedded script in https://secure.customer.com/admin/eventTracker/addCustomField.php:15) [setRadioButton] at script(event for HtmlRadioButtonInput[<input value="Tiny Text" type="radio" checked="checked" onclick="enableList( 'Tiny Text');" name="data_type">]:1) [setRadioButton] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [setRadioButton] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [setRadioButton] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [setRadioButton] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [setRadioButton] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [setRadioButton] at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:87) [setRadioButton] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302) [setRadioButton] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:733) [setRadioButton] at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107) [setRadioButton] at com.canoo.webtest.steps.form.SetRadioButton.setField(SetRadioButton.java:52) [setRadioButton] at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractSetFieldStep.java:124) [setRadioButton] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38) [setRadioButton] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [setRadioButton] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [setRadioButton] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[setRadioButton]        at org.apache.tools.ant.Task.perform(Task.java:364)
[setRadioButton] at org.apache.tools.ant.Target.execute(Target.java:341) [setRadioButton] at org.apache.tools.ant.Target.performTasks(Target.java:369) [setRadioButton] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [setRadioButton] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [setRadioButton] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [setRadioButton] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [setRadioButton] at org.apache.tools.ant.Main.runBuild(Main.java:668) [setRadioButton] at org.apache.tools.ant.Main.startAnt(Main.java:187) [setRadioButton] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [setRadioButton] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
[setRadioButton] == CALLING JAVASCRIPT ==
[setRadioButton] function () {
[setRadioButton]        [native code, arity=0]
[setRadioButton] }

[setRadioButton] ======= EXCEPTION END ========

INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully created.
... snip ...
********************* END: ERROR MESSAGE *********************

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest


_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to