From: Kent T. <ke...@cp...> - 2005-03-13 05:22:38
|
Hi, Here is a test html file: <html> <body> <script language="JavaScript"><!-- function foo() { document.form1.onsubmit=bar; } function bar() { alert('aaa'); return false; } window.onload=foo // --></script> <form name="form1"> <input type="Submit" name="OK" value="OK"/> </form> </body> </html> When I click OK, the browser will display an alert. But I don't know why no alert (zero) is captured when htmlunit is used to simulate the action: public void testOnSubmit() throws Exception { WebClient client = new WebClient(); CollectingAlertHandler handler = new CollectingAlertHandler(); client.setAlertHandler(handler); URL url = new URL("http://localhost:8080/TDDCalc/Test.html"); HtmlPage page = (HtmlPage) client.getPage(url); HtmlForm form = (HtmlForm) page.getAllForms().get(0); HtmlSubmitInput ok = (HtmlSubmitInput) form.getInputByName("OK"); ok.click(); assertEquals(handler.getCollectedAlerts().size(), 1); } |
From: Andrey S. <asu...@oi...> - 2005-03-14 06:57:13
|
> <input type="Submit" name="OK" value="OK"/> Perhaps it should be type="submit", i.e. lowercase. HtmlUnit is generally more picky about case-sensitivity than real browsers. Andrey |
From: Kent T. <ke...@cp...> - 2005-03-15 01:03:53
|
Andrey Subbotin wrote: > Perhaps it should be type="submit", i.e. lowercase. HtmlUnit is generally > more picky about case-sensitivity than real browsers. Thanks for the reply. I found that it's because onsubmit is not a writable property of the Form in htmlunit. Any idea why? Any plan to implement this? Thanks! -- Kent Tong, Msc, MCSE, SCJP, CCSA, Delphi Certified Manager of IT Dept, CPTTM Authorized training for Borland, Cisco, Microsoft, Oracle, RedFlag & RedHat |
From: Mike B. <mb...@Ga...> - 2005-03-15 12:16:30
|
Kent Tong wrote: > Thanks for the reply. I found that it's because onsubmit > is not a writable property of the Form in htmlunit. Any > idea why? Any plan to implement this? If the browsers allow something that HtmlUnit doesn't then it's just a matter of us not having got to that feature yet. If you open a feature request then somebody will implement that feature. Alternately, you could implement the feature yourself and submit a patch. In any case, we're implementing features as we need them or as people request them so make sure you open feature requests for anything you need that is missing. -- Mike Bowler President, Gargoyle Software Inc. Website: http://www.GargoyleSoftware.com Weblog : http://www.SphericalImprovement.com/blogs/mbowler/ |
From: Kent T. <ke...@cp...> - 2005-03-16 01:50:59
|
Mike Bowler wrote: > If the browsers allow something that HtmlUnit doesn't then it's just a > matter of us not having got to that feature yet. If you open a feature > request then somebody will implement that feature. Alternately, you > could implement the feature yourself and submit a patch. > > In any case, we're implementing features as we need them or as people > request them so make sure you open feature requests for anything you > need that is missing. Thanks for the reply. I believe the difficulty is that onsubmit is treated as an attribute whose value is a string. But when I assign to it, I am assigning an InterpretedFunction object to it. Can this problem be solved in the current architecture of HtmlUnit? If so, how? I'd like to help implement it but I know very little about HtmlUnit or Rhino. It took me a few hours with the debugger just to find out the difficulty above. -- Kent Tong, Msc, MCSE, SCJP, CCSA, Delphi Certified Manager of IT Dept, CPTTM Authorized training for Borland, Cisco, Microsoft, Oracle, RedFlag & RedHat |
From: Marc G. <mgu...@ya...> - 2005-03-16 08:56:13
|
> Thanks for the reply. I believe the difficulty is > that onsubmit is treated as an attribute whose value > is a string. But when I assign to it, I am assigning > an InterpretedFunction object to it. Can this problem > be solved in the current architecture of HtmlUnit? > If so, how? I'd like to help implement it but I know > very little about HtmlUnit or Rhino. It took me > a few hours with the debugger just to find out the > difficulty above. you first need to make changes in com.gargoylesoftware.htmlunit.javascript.host.Form to add js setter and getter for onsubmit like what is done in com.gargoylesoftware.htmlunit.javascript.host.HTMLElement for different event handlers. Then you have to get this javascript function called in place of the interpretation of the string attribute when the form is submitted. All these changes can be done with current architecture of htmlunit. Marc. |
From: Kent T. <ke...@cp...> - 2005-03-16 09:01:50
|
Marc Guillemot wrote: > you first need to make changes in > com.gargoylesoftware.htmlunit.javascript.host.Form to add js setter and > getter for onsubmit like what is done in > com.gargoylesoftware.htmlunit.javascript.host.HTMLElement for different > event handlers. Then you have to get this javascript function called in > place of the interpretation of the string attribute when the form is > submitted. All these changes can be done with current architecture of > htmlunit. Thanks for the help! I'll try it and see how it works! -- Kent Tong, Msc, MCSE, SCJP, CCSA, Delphi Certified Manager of IT Dept, CPTTM Authorized training for Borland, Cisco, Microsoft, Oracle, RedFlag & RedHat |
From: Sridhar R. <Sri...@Su...> - 2005-03-15 18:59:00
|
Hi, I saw the change history which goes into "next" build - which I presume 1.5 pre release. Where can I get the jar file for that ? I need it desperately as quite a few pages of my test needs the fixes set for this release. thanks Sridhar R |