简体   繁体   English

如何使用htmlunit设置内容框架

[英]How set content frame using htmlunit

I need to set the content HTML within an iframe, as pictured. 如图所示,我需要在iframe中设置内容HTML。

打印

1- Below, I get the frame. 1-在下面,我得到了框架。 But the frame does not have a setContent FrameWindow frame = page.getFrames().get(0); 但是框架没有setContent FrameWindow frame = page.getFrames()。get(0);

2- So I got BaseFrameElement. 2-所以我得到了BaseFrameElement。 But, how to put html code in content? 但是,如何将html代码放入内容中? BaseFrameElement frame = page.getFrames().get(0).getFrameElement(); BaseFrameElement框架= page.getFrames()。get(0).getFrameElement(); frame.setTextContent(textContent); frame.setTextContent(textContent);

If you have a better solution, let me know. 如果您有更好的解决方案,请告诉我。

Thank you. 谢谢。

Not sure that i understand your problem. 不确定我了解您的问题。 Usually some action on the page modifies the content of the iframe - there is no need to do this from the 'outside'. 通常,页面上的某些操作会修改iframe的内容-无需从“外部”执行此操作。

Try something like 尝试类似

BaseFrameElement base = page.getFrames().get(0);
base.getEnclosedWindow().setEnclosedPage(newPage);

Keep in mind that this will not trigger all the events and might not have the result you expect. 请记住,这不会触发所有事件,并且可能不会产生您期望的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM