0

I want to access the inner content of an embedded iframe with com.gargoylesoftware.htmlunit.WebClient:

<html>
<body>
<iframe...>
    #document
    <html>
    <body>
        ...
        <input name="myinput" />
    </body
</iframe>
</body>
</html>

I can already grab the iframe with:

HtmlInlineFrame iframe = (HtmlInlineFrame) page.getElementsByTagName("iframe").get(0);

Now I want to grab the input element. But even listing any input elements shows only an empty list:

NodeList inputs = iframe.getElementsByTagName("input");

So what might be wrong here? How can I access the inner of the embedded iframe?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

2

Try

HtmlInlineFrame iframe = (HtmlInlineFrame) page.getElementsByTagName("iframe").get(0);
HtmlPage innerPage = (HtmlPage) iframe.getEnclosedPage();
NodeList inputs = innerPage.getElementsByTagName("input");
RBRi
  • 2,704
  • 2
  • 11
  • 14