From: Brad C. <yo...@br...> - 2005-03-03 17:15:18
|
What do you mean when you say you can't access elements of the page? Is it throwing an exception? Do you get the wrong page back? Can you examine the server logs and see if things are getting requested as you expect them to be? --- nikola <web...@ya...> wrote: > Marc wrote: > > >you just need to access the enclosed page, for > >instance with: > > > final HtmlInlineFrame iframe = > >(HtmlInlineFrame)page.getHtmlElementById("i_frame"); > > final HtmlPage containedPage = (HtmlPage) > >iframe.getEnclosedPage(); > > > Marc. > > nikola wrote: > > hi, > > > > I want to access iframe content as I can acsess > "main" > > page content for example: > > > > main.php page > > > > <html> > > <head><title>title</title></head> > > <body> > > some content<br> > > <a href="link.php">link</a> > > <iframe id="i_frame" name="i_frame" > > src="main.php?content_id=1"></iframe> > > </body></html> > > > > ... now if I want to get link or iframe on this > main > > page, I know how to do it... > > final HtmlInlineFrame iframe = > > > (HtmlInlineFrame)page.getHtmlElementById("i_frame"); > > > > but i want to know if there is a way to access > content > > of this iframe page, how can I access > > main.php?content_id=1 from main.php in some way > > referencing iframe, to get elements of that second > > page... > > > > ... I know I can get srcAttribute of iframe, and > then > > load main.php?content_id=1 to a WebClient, but then > I > > can"t access elements of that page, for example if > > there is link I can"t get it > > > > final HtmlAnchor anchor = > > second_page.getAnchorByHref(" some_href"); > > > > ... I get an error ElementNotFound ... > > > > thank you Marc for your answer it was helpfull, but > ...:) > > I have tried your solution with some test example, I > have also found my own solution and also tried to > write some simple html pages to test it and also works > fine: > > [code] > final WebWindow secondWebWindow = > webClient.getWebWindowByName("my_iframe"); > assertInstanceOf(secondWebWindow, > BaseFrame.FrameWindow.class); > assertSame( firstPage, > ((BaseFrame.FrameWindow) > secondWebWindow).getEnclosingPage() ); > //assertEquals( "SomeTitle", > ((HtmlPage)secondWebWindow.getEnclosedPage()).getTitleText() > ); > > [code] > > , but both solution don't work in my web application > ... > > ... my main page is protected (with login ...), and I > can simulate login, and it works fine, I can then > access all elements with no problem ... the second > page (which is contained in iframe) it's even not > protected, and I can't access elements of that page > ... and neither page is complex or something like > that, both pages are simple html pages generated by > php and I can't understand what's wrong with that > pages, so if anyone had similar problems, please reply > ... > > Nikola > > > > > __________________________________ > Celebrate Yahoo!'s 10th Birthday! > Yahoo! Netrospective: 100 Moments of the Web > http://birthday.yahoo.com/netrospective/ > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |