【发布时间】:2011-01-06 18:29:37
【问题描述】:
我如何告诉 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 的源代码中,所以我希望它像其他浏览器一样默认可用。我找不到任何关于如何启用它的说明。
【问题讨论】:
-
我也用 selenium-rc 标记了这个,因为我不介意我使用 Selenium 2 还是 Selenium-RC。
标签: python selenium-rc htmlunit selenium-webdriver