From: Kent T. <ke...@cp...> - 2005-03-12 13:05:43
|
Hi, It seems that the onsubmit handler is not called when I call submit() on the form. Here is a test html file: <html> <body> <script language="JavaScript"><!-- function foo() { alert('ddd'); } // --></script> <form name="form1" onsubmit="foo()"> <input type="Submit" name="OK" value="OK"/> </form> </body> </html> The test case below fails: public class OnsubmitTest extends TestCase { 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); form.submit(); assertEquals(handler.getCollectedAlerts().size(), 1); } } If I use a real browser, it does show the alert. Any idea? TIA! |