0

How can i insert some iframes inside a HTML page's iframe.

<HTML>
  <div id="data">
    <iframe height="160" width="600">
    </iframe>
  </div>
</HTML>

i could able to find the specific location using xpath

HtmlInlineFrame frame = (HtmlInlineFrame)page.getByXPath("//div[@id='data']/iframe").get(0);

i'm not clear how can i insert another htmlpage (iframe as htmlpage) inside this selected iframe. i have to insert more than one htmlpage (iframes as htmlpages) into this iframe Please suggest some way.

RDD
  • 145
  • 1
  • 18
  • i refered [here](http://stackoverflow.com/questions/3667352/htmlunit-and-xpath-domnode-getbyxpath-only-works-on-htmlpage) but didn't get solution. – RDD Jul 15 '14 at 11:19

1 Answers1

0
((HtmlInlineFrame)page1.getByXPath("//div[@id='data']/iframe").get(0)).setTextContent(page2.asXml());

this will work, still there is a problem that, there is a parser working in between, that is content set as

page2.asXml();

will set the content. After that when viewing the page as xml all '<' replaced with &lt; and '>' replaced with &gt;

((HtmlInlineFrame)page1.getByXPath("//div[@id='data']/iframe").get(0)).appendChild(page2);

will fix earlier issue still it will add two unwanted lines

RDD
  • 145
  • 1
  • 18
  • Setting text content seems pretty efficient :-). You can use "page.getFrameByName(name)" to get frame, in case the "id" attributes is liable to change and that removes the need for the cast. – Paddy Jul 15 '14 at 13:12