HtmlUnit不会加载外部引用的javascript [英] HtmlUnit doesn't load externally referenced javascript

查看:89
本文介绍了HtmlUnit不会加载外部引用的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用HtmlUnit测试Web应用程序时遇到问题.请记住,我没有使用HtmlUnit很久了,所以我可能会丢失一些琐碎的东西.

I have run into a problem while trying to test a web application with HtmlUnit. Please bear in mind that I haven't used HtmlUnit very long so I might be missing something trivial.

由于某些原因,未加载外部引用的javascript.当我将页面打印为xml时,我得到的就是这样:

For some reason externally referenced javascripts aren't being loaded. When I print the page as xml all i get is this:

<script language="javascript" src="urltofile.js">  
</script>  

您可以看到script标记应包含javascript时为空.我想念什么?我整个上午都在谷歌上寻找解决方案,但没有找到任何相关信息.任何帮助将不胜感激!

As you can see the script tag is empty when it should contain the javascript. What am I missing? I have googled for a solution all morning but haven't found any relevant information. Any help would be greatly appreciated!

推荐答案

经过数小时的搜寻,我发现解决方案非常简单.我要做的就是在检索页面后等待几秒钟,以使javascript有一定的执行时间,然后再执行其他操作.老实说,找到解决方案有点反高潮,但至少我现在可以继续研究更重要的内容. :)

After many many hours of googling I found the solution to be very simple. All I had to do was to wait a few seconds after the page is retrieved to allow the javascript some time to execute before doing anything else. I can honestly say finding the solution was a bit of an anticlimax, but at least I can move along to more important stuff now. :)

这篇关于HtmlUnit不会加载外部引用的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆