|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
"Form" is not a constructorI’ve recently come across a problem when the
JavaScriptEngine.execute(…) method executes the following line of
JavaScript: currentForm = document.getElementById("formName"); … where “formName” is the id of a form
on the page. The exception that is thrown is: org.mozilla.javascript.WrappedException:
Wrapped com.gargoylesoftware.htmlunit.ScriptException: "Form" is not
a constructor. (javascript file name#105)
(javascript file name #105) I’m using the following BrowserVersion: public static final
BrowserVersion IE_6_0_SP2_on_WINXP_SP2 = new BrowserVersion(
BrowserVersion.INTERNET_EXPLORER, "4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322)", "1.2", 6 ); I’ve walked through the functionality using the real
browser that the above BrowserVersion represents as well as FireFox 1.0.7 and I’m
not seeing any JavaScript errors on the page when it loads. I’m also using a build of HtmlUnit 1.7 from 2005-12-05. Any ideas as to what would cause this Exception? Thanks in advance, Tom |
|
|
Re: "Form" is not a constructorHi Thomas,
is currentForm = document.getElementById("formName"); really the code at line 105 in your js file? Can you try to produce a minimal html/js reproducing the problem? Marc. Thomas Robbs wrote: > I’ve recently come across a problem when the JavaScriptEngine.execute(…) > method executes the following line of JavaScript: > > > > currentForm = document.getElementById("formName"); > > > > … where “formName” is the id of a form on the page. > > > > The exception that is thrown is: > > > > org.mozilla.javascript.WrappedException: Wrapped > com.gargoylesoftware.htmlunit.ScriptException: "Form" is not a > constructor. (/javascript file name/#105) (/javascript file name/ #105) > > > > I’m using the following BrowserVersion: > > > > public static final BrowserVersion IE_6_0_SP2_on_WINXP_SP2 = new > BrowserVersion( > > BrowserVersion.INTERNET_EXPLORER, "4.0 (compatible; MSIE 6.0; > Windows NT 5.1; SV1; .NET CLR 1.1.4322)", > > "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET > CLR 1.1.4322)", "1.2", 6 ); > > > > I’ve walked through the functionality using the real browser that the > above BrowserVersion represents as well as FireFox 1.0.7 and I’m not > seeing any JavaScript errors on the page when it loads. > > > > I’m also using a build of HtmlUnit 1.7 from 2005-12-05. > > > > Any ideas as to what would cause this Exception? > > > > Thanks in advance, > > > > Tom > > > > > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
|
|
|
RE: Re: "Form" is not a constructorPlease provide the patch for prototype.js as I'm having the same issue on my project. Thanks, Matt |
|
|
Re: RE: Re: "Form" is not a constructorMatt,
when you (or someone else) is able to provide an example of the failing code, perhaps could we fix it in htmlunit itself... Marc. mraible (sent by Nabble.com) wrote: > Ben Kyrlach wrote: > I've also experienced this problem before. Unfortunantly, I was > unable to isolate the problematic code from the application under > test. If you're using "prototype.js" (a standard javascript library > it seems) I've found that a simple modification to that JS file > solved my problem. > > Please provide the patch for prototype.js as I'm having the same issue > on my project. > > Thanks, > > Matt > ------------------------------------------------------------------------ > View this message in context: RE: Re: "Form" is not a constructor > <http://www.nabble.com/%22Form%22-is-not-a-constructor-t716240.html#a2212276> > Sent from the HtmlUnit - General > <http://www.nabble.com/HtmlUnit---General-f2599.html> forum at Nabble.com. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
|
|
|
Re: RE: Re: "Form" is not a constructorHere is a file which exhibits the error - just click on the button - change Form to Form1 in 2 places and it no longer breaks:
<html> <head> <script type="text/javascript"> <!-- var Form = { getElements: function(form) { form = $(form); var elements = new Array(); for (tagName in Form.Element.Serializers) { var tagElements = form.getElementsByTagName(tagName); for (var j = 0; j < tagElements.length; j++) elements.push(tagElements[j]); } return elements; } } function validate() { currentForm = document.getElementById('formId'); currentForm.field1.value="fred"; return false; } // --> </script> </head> <body> <form id='formId' name='formName'> <input type="text" name="field1" value="barney"> <input type="button" type="submit" id="submit" onClick="validate()"> </form> </body> </html> If it helps, here is a WebTest script for clicking the link: <target name="main"> <property name="testfile" location="checkJavaScript.html"/> <webtest name="prototype.js bug"> <config summary="true" saveresponse="true" showhtmlparseroutput="false"/> <steps> <invoke url="file:///${testfile}"/> <clickButton htmlId="submit" /> <verifyInputField name="field1" value="fred"/> </steps> </webtest> </target> |
|
|
Re: "Form" is not a constructorOk, I've understood the problem: Form is newly defined and when we want to
create the JS object for the form trying to call our JS host object through its constructor, it has been replaced by the local "Form" object. This will be quite simple to fix, just using an other name for the internal use of the object. I guess that the problem occurs with other of htmlunit's host classes and I will try to check them all. Marc. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
Re: "Form" is not a constructorPlease let me know when this is fixed in CVS - I'd be more than happy to test.
|
|
|
Re: "Form" is not a constructormraible (sent by Nabble.com) wrote:
> Please let me know when this is fixed in CVS - I'd be more than happy to > test. sure. I thought that I could fix it this evening but it is a bit more complicated as I thougt, I will post a message when it is fixed (I hope this week). Marc. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
Re: "Form" is not a constructorMatt,
this should now work for Form. The work needs to be extended to definitely avoid name conflicts. I won't ship a new htmlunit jar to webtest until this is done but you can already build one by yourself from htmlunit's public CVS and use it in place of the provided one in the latest webtest build. Marc. mraible (sent by Nabble.com) wrote: > Please let me know when this is fixed in CVS - I'd be more than happy to > test. > ------------------------------------------------------------------------ > View this message in context: Re: "Form" is not a constructor > <http://www.nabble.com/%22Form%22-is-not-a-constructor-t716240.html#a2279743> > Sent from the HtmlUnit - General > <http://www.nabble.com/HtmlUnit---General-f2599.html> forum at Nabble.com. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
Re: "Form" is not a constructorI checked out and built from CVS, but no luck - the error is still there. I suspect SF's anonymous CVS hasn't synchronized yet? Is there anyway to post a snapshot or send me the JAR? mraible AT Gmail.
Thanks, Matt |
|
|
Re:mraible (sent by Nabble.com <lists <at> nabble.com> writes:
> > > I checked out and built from CVS, but no luck - the error is still there. I suspect SF's anonymous CVS hasn't synchronized yet? Is there anyway to post a snapshot or send me the JAR? mraible AT Gmail. > Thanks, > Matt > > View this message in context: Re: "Form" is not a constructor > Sent from the HtmlUnit - General forum at Nabble.com. > I've checked through the public ViewCVS and the change seems now to be available. Generally you can use the diff that is automatically posted to the dev mailing list after each commit and apply it locally when you don't want to wait for the public CVS to be updated. Marc. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
Re: Re:Thanks Marc - works great!
|
|
|
Re: Re:I am running into this same problem and am wondering if the newest version of HtmlUnit (1.8 released in February) had this fix. I even tried building from CVS (now a 1.9 prerelease) with no luck. If possible, however, is there some modifications that I can do myself so that I can still use HtmlUnit 1.7? I have a bunch of other test cases that have now deprecated methods and would like to avoid a refactor.
|
|
|
Re: Re:Hi,
if you want to delay your refactoring work, you have to avoid the use of a js variable named Form... or backport the fix for this problem to htmunit 1.7. Nevertheless I guess that it is less work to upgrade to htmlunit 1.8 and this makes you ready to benefit from the next fix that you will need ;-) Marc. |
| Free embeddable forum powered by Nabble | Forum Help |