HtmlUnit 有多稳定、多快
我正在从 selenium-1 升级到 selenium-2 并尝试新的 HtmlUnit 驱动程序。我已经尝试了一些基本的测试(打开一个页面,get_text,..),它看起来
- 非常慢(我认为 chrome/FF 远程驱动程序比它更快)
- ,非常不稳定(使用 HTMLUNIT 打开 yahoo.com)和 HTMLUNITWITHJS 都导致了错误)
我很高兴听到您对它的印象。我希望你会发现我错了(没有(1)速度我可以生活,但(2)稳定性至关重要)?有 HtmlUnit 与 selenium 驱动程序的速度比较吗?
I'm upgrading from selenium-1 to selenium-2 and trying out the new HtmlUnit driver. I've tried a few basic tests on it (open a page, get_text,..) and it seems
- Extremely slow (I think the chrome/FF remote drivers are faster than it)
- Extremely un-stable (opening yahoo.com using HTMLUNIT and HTMLUNITWITHJS both resulted in errors)
I'd be very happy to hear your impression of it. I hope you'll find I'm wrong (I can live without (1) speed but (2) stability is critical)? is there a speed comparison of HtmlUnit vs the selenium drivers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,HtmlUnit 比 Firefox 快得多,明显比 chrome 快(这是使用 selenium 2.0rc2 的最快的完整浏览器)。 HtmlUnit 不需要下载外部资源,如果您在没有 BrowserVersion 的情况下使用它,则默认情况下会禁用 javascript:
但是如果您传入浏览器版本,则会启用它,但运行速度会较慢,因为它将下载 javascript 文件:
话虽如此,javascript 无法与真正的浏览器相媲美。 Google 和 Yahoo 的主页无法正常工作。现代浏览器可以容忍某些 javascript 错误(漏洞利用/黑客攻击),而 HtmlUnit 则不能。
我通常在不需要大量 JavaScript 的页面/流程上使用 HtmlUnitDriver,我只需要验证页面上存在的元素/数据(不是动态加载的)。
In my experience HtmlUnit is much faster than Firefox, noticeably faster than chrome (which is the fastest full browser with selenium 2.0rc2). HtmlUnit does not need to download external resources and if you use it without a BrowserVersion then javascript is disabled by default:
But if you pass in a browser version then it is enabled, but runs slower since it will download the javascript files:
That being said, the javascript is not up to par with real browsers. Google's and Yahoo's homepage don't work properly. Modern browsers are tolerant to certain javascript errors (exploits / hacks), while HtmlUnit is not.
I usually use HtmlUnitDriver on pages / flows that don't require heavy javascript and I just need to verify elements / data existing on pages (that are not dynamically loaded).
您还可以按如下方式启用 JavaScript。
((HtmlUnitDriver) 驱动程序).setJavascriptEnabled(true);
you can also enable javascript as follows.
((HtmlUnitDriver) driver).setJavascriptEnabled(true);