[Webtest] Enabling JavaScript errors

Jeff Nielsen webtest@lists.canoo.com
Wed, 9 Apr 2003 22:25:17 -0400


To have HttpUnit ignore JavaScript exceptions on scripts that it can't
process for some reason, set the following before running Canoo.

    HttpUnitOptions.setExceptionsThrownOnScriptError(false);

I added this to the static initializer of
com.canoo.webtest.ant.TestSpecificationTask.  By doing this, I found that
WebTest was able to process a lot of my JavaScript stuff "out of the box".
(I did end up adding a few of my own tags to WebTest to make even more
JavaScript Work).

Jeff Nielsen
Digital Focus
www.digitalfocus.com


----- Original Message -----
From: "Matt Raible" <matt@raibledesigns.com>
To: <webtest@gate.canoo.com>
Sent: Wednesday, April 09, 2003 12:44 PM
Subject: [Webtest] Enabling JavaScript errors


> I'm trying to turn on JavaScript in my webtest tests, and I'm getting the
> following error.  The method I used to turn on JavaScript was adding
js.jar
> to my classpath.
>
> Thanks,
>
> Matt
>
> failed: ConversionError: The undefined value has no properties.
>
> Full Details:
>
> file:c:/Source/cct/dbping.xml:42: Test failed.
> Exception raised: com.meterware.httpunit.ScriptException: Script 'if
> (getCookie("username") != null)
>  {
>         document.getElementById("j_username").value =
getCookie("username");
>         document.getElementById("j_password").focus();
>     } else {
>         document.getElementById("j_username").focus();
>     }
>
>     function saveUsername(theForm) {
>         var expires = new Date();
>         expires.setTime(expires.getTime() + 24 * 30 * 60 * 60 * 1000); //
> sets it for approx 30 days
> .
>         setCookie("username",theForm.j_username.value,expires,"/");
>
>         if (theForm.rememberMe.checked) {
>             setCookie("password",theForm.j_password.value,expires,"/");
>             setCookie("rememberMe","true",expires,"/");
>         }
>     }
>
>     function validateForm(form) {
>         return validateRequired(form);
>     }
>
>     function required () {
>         this.aa = new Array("j_username", "E-Mail Address is a required
> field.", new Function ("varN
> ame", " return this[varName];"));
>         this.ab = new Array("j_password", "Password is a required field.",
> new Function ("varName",
> " return this[varName];"));
>     }
> // -->' failed: ConversionError: The undefined value has no properties.
> (httpunit; line 238)com.mete
> rware.httpunit.ScriptException: Script 'if (getCookie("username") != null)
{
>         document.getElementById("j_username").value =
getCookie("username");
>         document.getElementById("j_password").focus();
>     } else {
>         document.getElementById("j_username").focus();
>     }
>
>     function saveUsername(theForm) {
>         var expires = new Date();
>         expires.setTime(expires.getTime() + 24 * 30 * 60 * 60 * 1000); //
> sets it for approx 30 days
> .
>         setCookie("username",theForm.j_username.value,expires,"/");
>
>         if (theForm.rememberMe.checked) {
>             setCookie("password",theForm.j_password.value,expires,"/");
>             setCookie("rememberMe","true",expires,"/");
>         }
>     }
>
>     function validateForm(form) {
>         return validateRequired(form);
>     }
>
>     function required () {
>         this.aa = new Array("j_username", "E-Mail Address is a required
> field.", new Function ("varN
> ame", " return this[varName];"));
>         this.ab = new Array("j_password", "Password is a required field.",
> new Function ("varName",
> " return this[varName];"));
>     }
> // -->' failed: ConversionError: The undefined value has no properties.
> (httpunit; line 238)
>         at
>
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptEx
ce
> ption(JavaS
> cript.java:176)
>         at
>
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.executeScript
> (JavaScript.ja
> va:113)
>         at com.meterware.httpunit.scripting.ScriptableDelegate.runScript
> (ScriptableDelegate.java:55)
>
>         at com.meterware.httpunit.WebResponse$Scriptable.load
> (WebResponse.java:574)
>         at com.meterware.httpunit.javascript.JavaScript$Window.initialize
> (JavaScript.java:364)
>         at com.meterware.httpunit.javascript.JavaScript.run
> (JavaScript.java:79)
>         at
com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate
> (JavaScriptEngineFacto
> ry.java:46)
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>