0
我試圖使用Selenium在運行瀏覽器交互的機器上上傳960KB文件,使用send_keys,該文件正在發送到不同的機器。目前這不起作用,我在下面找到以下回溯。然而,當圖像或小型壓縮文件被上傳時,它是有效的(所以我不認爲這是上傳壓縮文件的問題,這是其他人遇到的問題)。我試圖在發帖前搜索主題:selenium:使用python上傳使用send_keys的大文件
https://groups.google.com/forum/#!msg/selenium-users/dlxoowrZYeA/24kPjqRW2FcJ[1-25] http://grokbase.com/t/gg/selenium-developer-activity/124tpkyzmq/issue-3812-in-selenium-python-can not-upload-a-file
但是在建議編輯之後,它仍然不起作用。 我使用硒2.25.0,一個CentOS 6.3操作系統和Python 2.6.6
Traceback (most recent call last):
File "/home/testrunner/Suite/CATS/cobalt/cobalttest.py", line 270, in run
testMethod()
File "/home/testrunner/Suite/CATS/mhetest/psmBaseSetupModule.py", line 549, in runTest
PSM.command().find_element_by_name('location').send_keys( 'filename.tar.gz')
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 144, in send_keys
value = self._upload(local_file)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 228, in _upload
{'file': base64.encodestring(fp.getvalue())})['value']
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 205, in _execute
return self._parent.execute(command, params)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 283, in execute
return self._request(url, method=command_info[0], data=data)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 324, in _request
response = opener.open(request)
File "/usr/lib/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1190, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.6/urllib2.py", line 1163, in do_open
r = h.getresponse()
File "/usr/lib/python2.6/httplib.py", line 990, in getresponse
response.begin()
File "/usr/lib/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
**raise BadStatusLine(line)
BadStatusLine**