如果運行在[Errno 111] Connection refused
錯誤的腳本結果像這樣:
% test.py
E
======================================================================
ERROR: test_test (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/unutbu/pybin/test.py", line 11, in setUp
self.selenium.start()
File "/data1/unutbu/pybin/selenium.py", line 189, in start
result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL, self.extensionJs])
File "/data1/unutbu/pybin/selenium.py", line 219, in get_string
result = self.do_command(verb, args)
File "/data1/unutbu/pybin/selenium.py", line 207, in do_command
conn.request("POST", "/selenium-server/driver/", body, headers)
File "/usr/lib/python2.6/httplib.py", line 898, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.6/httplib.py", line 935, in _send_request
self.endheaders()
File "/usr/lib/python2.6/httplib.py", line 892, in endheaders
self._send_output()
File "/usr/lib/python2.6/httplib.py", line 764, in _send_output
self.send(msg)
File "/usr/lib/python2.6/httplib.py", line 723, in send
self.connect()
File "/usr/lib/python2.6/httplib.py", line 704, in connect
self.timeout)
File "/usr/lib/python2.6/socket.py", line 514, in create_connection
raise error, msg
error: [Errno 111] Connection refused
----------------------------------------------------------------------
Ran 1 test in 0.063s
FAILED (errors=1)
則解決方案是最有可能的,你需要得到硒服務器首先運行。
在下載SeleniumRC時,會發現一個名爲selenium-server.jar的文件(截至幾個月前,該文件位於SeleniumRC/selenium-server-1.0.3/selenium-server.jar
)。
在Linux上,你可以用命令
java -jar /path/to/selenium-server.jar 2>/dev/null 1>&2 &
你會發現關於如何設置服務器here更完整的說明在後臺運行硒服務器。
這些錯誤是什麼? – MAK 2011-03-04 20:32:21
我跑了你的腳本沒有問題。在運行腳本之前是否啓動了硒服務器? – unutbu 2011-03-04 20:42:35
Selenium服務器?我只下載了Selenium Client Driver和Selenium IDE。 – sophiaw 2011-03-04 21:21:00