From: Erskine, C. <chr...@ED...> - 2004-09-30 16:07:11
|
I know that there is some bug in this processing. When I submit a form with a target of '_top' in a frame using javascript, the page returned is not the top level page that you would expect. I am trying to chase this down some more to identify what page is being returned and who is causing the problem of the wrong page being returned. Chris Erskine EDS Consulting Services F5-EDS-001 2424 Garden of the Gods Rd Colorado Springs, CO 80919 Phone: 719-535-6064 Phone: mailto:chr...@ed... -----Original Message----- From: David D.Kilzer [mailto:ddk...@ki...] Sent: Thursday, September 30, 2004 9:53 AM To: htm...@li... Cc: Elise Lebeau Subject: Re: [Htmlunit-user] Problem refreshing frame content On Jun 25, 2004, at 5:16 PM, Elise Lebeau wrote: > A form is submitted and one of the app frames is updated with > information > using javascript. > The problem is that I always end up in blank.html inseatd of the > updated > info. Whenever a link is clicked or a form submitted (or a new page loaded via JavaScript), htmlunit will return a new Page object which contains the updated content. If you continuously refer to the "original" Page object, you will only see the original content loaded on that page. See below for comments on where new pages are being returned (that you're ignoring) in the code. I don't have much experience with using frames, but I'm pretty sure they're going to work the same way (except that you may only get updates to individual frames instead of the whole frameset document). > This is the test case: > WebClient webClient = new WebClient(); > URL url = new > URL("http://127.0.0.1:8080/cudl/cudlQA.html"); > > // Get the test frames page > HtmlPage main = (HtmlPage)webClient.getPage(url); > List mainFrameset = main.getFrames(); > HtmlFrame testFrame1 = (HtmlFrame)mainFrameset.get(1); > HtmlPage test = (HtmlPage)testFrame1.getEnclosedPage(); > HtmlFrame testFrame2 = (HtmlFrame)test.getFrames().get(0); > HtmlPage testExec = (HtmlPage)testFrame2.getEnclosedPage(); > > //setup some fields in the form > ((HtmlAnchor) testExec.getAnchors().get(0)).click(); New page is returned here (ignored). > //submit the form to update the display frame > ((HtmlAnchor) testExec.getAnchors().get(2)).click(); New page is returned here (ignored). > //make sure that the page has time to reload > Thread.sleep(1000 * 10); This is not necessary. Htmlunit will block until the page is fully loaded. > final HtmlFrame appFrame = > ((HtmlFrame)mainFrameset.get(0)); This is an old copy of the page (frameset) you're using here. > final HtmlPage app = (HtmlPage)appFrame.getEnclosedPage(); Still using an old copy of the page. > List modelFrame = app.getFrames(); Old copy. > final HtmlPage display = > (HtmlPage)((HtmlFrame)modelFrame.get(0)).getEnclosedPage(); Old copy. > System.out.println(display.getTitleText());the display > page is > blank.html. Old copy. :) Dave ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |