From: David D.K. <ddk...@ki...> - 2004-09-30 15:53:55
|
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 |