From: Kent T. <ke...@cp...> - 2005-03-13 05:15:44
|
Hi, Somehow the onload event is called twice. Here is a test html file: <html> <body> <script language="JavaScript"><!-- function foo() { alert('aaa'); } window.onload=foo // --></script> <form name="form1"> <input type="Submit" name="OK" value="OK"/> </form> </body> </html> The test case below fails: 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); } If I use a real browser, it shows the alert just once. Any idea? TIA! |