如何告诉 Selenium 使用 HTMLUnit?
我在后台运行 selenium-server-standalone-2.0b1.jar 作为 Selenium 服务器,并使用“pip install -U selenium”安装最新的 Python 绑定。
Firefox 一切正常。但我想使用 HTMLUnit,因为它重量更轻,不需要 X。这是我这样做的尝试:
>>> import selenium
>>> s = selenium.selenium("localhost", 4444, "*htmlunit", "http://localhost/")
>>> s.start()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 189, in start
result = self.get_string("getNewBrowserSession", start_args)
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 223, in get_string
result = self.do_command(verb, args)
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 217, in do_command
raise Exception, data
Exception: Failed to start new browser session: Browser not supported: *htmlunit
Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
那么问题来了,HTMLUnit驱动叫什么?如何启用它?
HTMLUnit 的代码似乎在 Selenium 2 的源代码中,所以我希望它像其他浏览器一样默认可用。我找不到有关如何启用它的任何说明。