HtmlUnit is a "GUI-Less browser for
Java programs". It models HTML
documents and provides an API that
allows you to invoke pages, fill out
forms, click links, etc... just like
you do in your "normal" browser.
It has fairly good JavaScript support
(which is constantly improving) and is
able to work even with quite complex
AJAX libraries, simulating either
Firefox or Internet Explorer depending
on the configuration you want to use.
It is typically used for testing
purposes or to retrieve information
from web sites.
您可以使用Selenium或Watir来驱动真正的浏览器。
还有一些基于JavaScript的无头浏览器:
就我个人而言,我最熟悉的是Selenium,它支持用大量的语言编写自动化脚本,并且有更成熟的工具,比如Firefox优秀的Selenium IDE扩展,可以用来编写和运行测试用例,还可以将测试脚本导出到多种语言。
使用HtmlUnit也是一种可能性。
Selenium现在包装htmlunit,这样您就不需要再启动浏览器了。新的WebDriver api也很容易使用。The first example use htmlunit driver
相关问题 更多 >
编程相关推荐