From: Kevin M. <km...@se...> - 2005-08-08 15:31:13
|
Hey all, I'm fairly new to HtmlUnit, so apologies if this has been covered before (the only related message I could find in the archives was over a year old). Basically, I have a form with a check box and when the box is clicked it fires off a JavaScript event that submits the form. The click() method, however, is not returning the new page after the form submission but rather the page that the check box was contained in. Is this not the correct approach to capturing that new page instance? Thanks, Kevin |
From: Brad C. <yo...@br...> - 2005-08-08 15:51:34
|
That was fixed in 1.3 and there is a unit test for it. Brad C --- Kevin Menard <km...@se...> wrote: > Hey all, > > I'm fairly new to HtmlUnit, so apologies if this has been covered > before (the only related message I could find in the archives was > over a year old). Basically, I have a form with a check box and when > the box is clicked it fires off a JavaScript event that submits the > form. The click() method, however, is not returning the new page > after the form submission but rather the page that the check box was > contained in. Is this not the correct approach to capturing that new > page instance? > > Thanks, > Kevin > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |
From: Kevin M. <km...@se...> - 2005-08-08 16:00:57
|
On Aug 8, 2005, at 11:51 AM, Brad Clarke wrote: > That was fixed in 1.3 and there is a unit test for it. Okay, well I'm using 1.6. So any thoughts as to what may be going wrong? Just to give a snippet of what I'm doing: final HtmlPage nextPage = (HtmlPage) getForm().getInputByName ("sameShippingInfo").click(); final HtmlForm form = nextPage.getFormByName("add"); where getForm() is a method I have that returns the only form for the current page. nextPage gets set to the current page and form gets set to the same form that getForm() returns. Any help would be appreciated. Thanks, Kevin |
From: Marc G. <mgu...@ya...> - 2005-08-08 16:05:10
|
Which version do you use? May your form be submitted in an other window / frame? Marc. Kevin Menard wrote: > > On Aug 8, 2005, at 11:51 AM, Brad Clarke wrote: > >> That was fixed in 1.3 and there is a unit test for it. > > > Okay, well I'm using 1.6. So any thoughts as to what may be going wrong? > > Just to give a snippet of what I'm doing: > > final HtmlPage nextPage = (HtmlPage) getForm().getInputByName > ("sameShippingInfo").click(); > final HtmlForm form = nextPage.getFormByName("add"); > > where getForm() is a method I have that returns the only form for the > current page. > > nextPage gets set to the current page and form gets set to the same > form that getForm() returns. > > Any help would be appreciated. > > Thanks, > Kevin > > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |
From: Kevin M. <km...@se...> - 2005-08-08 17:13:11
|
On Aug 8, 2005, at 12:08 PM, Marc Guillemot wrote: > Which version do you use? May your form be submitted in an other > window / frame? I'm using HtmlUnit 1.6 and this is all in a single frame. What I have is a Tapestry webapp with a form. The check box's onclick event has some Javascript that submits the form. Tapestry's listener gets called in response and redirects to a new page. This behavior has been verified in every major web browser, so it's not that the form is not causing the redirect. -- Kevin |
From: Marc G. <mgu...@ya...> - 2005-08-10 01:35:13
|
Quite strange. Can you log the currently opened windows using WebClient.getWebWindows()? Can you check if the page is really the one that is currently loaded in the window: nextPage == nextPage.getEnclosingWindow().getEnclosedPage() Marc. Kevin Menard wrote: > > On Aug 8, 2005, at 12:08 PM, Marc Guillemot wrote: > >> Which version do you use? May your form be submitted in an other >> window / frame? > > > I'm using HtmlUnit 1.6 and this is all in a single frame. What I have > is a Tapestry webapp with a form. The check box's onclick event has > some Javascript that submits the form. Tapestry's listener gets called > in response and redirects to a new page. This behavior has been > verified in every major web browser, so it's not that the form is not > causing the redirect. > |
From: Kevin M. <km...@se...> - 2005-08-11 12:50:06
|
On Aug 9, 2005, at 3:09 AM, Marc Guillemot wrote: > Quite strange. Can you log the currently opened windows using > WebClient.getWebWindows()? Can you check if the page is really the > one that is currently loaded in the window: nextPage == > nextPage.getEnclosingWindow().getEnclosedPage() I'll give this a shot, but in the meanwhile, I noticed something odd. If I set a breakpoint in the webapp to handle the form submit, it turns out it never gets hit. So, I think HtmlUnit is just not executing the onclick handler correctly. The rendered HTML for this checkbox is the following: <input type="checkbox" name="sameShippingInfo" id="sameShippingInfo" onchange="javascript:this.form.submit();"/> I've worked around this in the interim by simply calling form.submit () and setting a couple of others things up to simulate the clicking of the checkbox. Calling form.submit() will submit the form and redirect to the correct page. Any further thoughts on this? Thanks, Kevin |
From: Marc G. <mgu...@ya...> - 2005-08-11 12:55:30
|
Kevin Menard wrote: > On Aug 9, 2005, at 3:09 AM, Marc Guillemot wrote: > >> Quite strange. Can you log the currently opened windows using >> WebClient.getWebWindows()? Can you check if the page is really the one >> that is currently loaded in the window: nextPage == >> nextPage.getEnclosingWindow().getEnclosedPage() > > > I'll give this a shot, but in the meanwhile, I noticed something odd. > If I set a breakpoint in the webapp to handle the form submit, it turns > out it never gets hit. So, I think HtmlUnit is just not executing the > onclick handler correctly. The rendered HTML for this checkbox is the > following: > > <input type="checkbox" name="sameShippingInfo" id="sameShippingInfo" > onchange="javascript:this.form.submit();"/> > > I've worked around this in the interim by simply calling form.submit() > and setting a couple of others things up to simulate the clicking of the > checkbox. Calling form.submit() will submit the form and redirect to > the correct page. > > Any further thoughts on this? have you tried onchange="this.form.submit();" Marc. |
From: Kevin M. <km...@se...> - 2005-08-11 13:28:45
|
On Aug 11, 2005, at 8:59 AM, Marc Guillemot wrote: > have you tried > onchange="this.form.submit();" That had no effect. The click() method is still returning the current page instance. I'll try your previous suggestions. Thanks again for your help, Kevin |
From: Kevin M. <km...@se...> - 2005-08-30 21:11:15
|
On Aug 11, 2005, at 9:28 AM, Kevin Menard wrote: > > On Aug 11, 2005, at 8:59 AM, Marc Guillemot wrote: > >> have you tried >> onchange="this.form.submit();" > > That had no effect. The click() method is still returning the > current page instance. > I finally attached the source to the debugger and stepped through the code. Turns out the issue is that HtmlUnit only handles onclick events. Changing my event from onchange to onclick made everything work. -- Kevin |