0

我正在尝试使用 Selenium 在使用send_keys运行浏览器交互的机器上上传一个 960KB 的文件,该文件正在发送到另一台机器。目前这不起作用,我在下面得到以下回溯。但是,当上传图像或小型压缩文件时它可以工作(所以我认为上传压缩文件不是问题,这是其他人遇到的问题)。我在发布之前尝试搜索主题:

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-无法上传文件

但是,在进行建议的编辑后,它仍然无法正常工作。我正在使用 selenium 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**
4

1 回答 1

0

将 Firefox 降级到 Firefox 5 时问题已解决。我不确定如何使用更新版本的 Firefox 上传文件。

于 2012-08-10T14:21:21.383 回答