【问题标题】:selenium: Uploading a large file using send_keys using pythonselenium:使用 python 使用 send_keys 上传大文件
【发布时间】:2012-08-09 13:47:28
【问题描述】:

我正在尝试使用 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-cannot-upload-a-file

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

【问题讨论】:

    标签: selenium centos python-2.6


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-27
      • 2020-11-26
      • 2022-10-16
      • 2021-02-08
      • 2017-10-02
      • 2021-06-12
      • 2020-09-02
      • 2022-11-25
      相关资源
      最近更新 更多