You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Selenium 4/Chromedriver 128后Capybara测试出现畸形请求报错

Selenium 3 升级至 Selenium 4 后 Capybara 功能测试出现无效请求问题

问题详情

将Selenium 3升级至Selenium 4后,所有Capybara功能测试都会触发两个无效请求,Puma日志中输出如下错误:

2024-02-06 09:38:36 -03 HTTP parse error, malformed request: #<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>

我的Chromedriver配置代码如下:

Capybara.register_driver :chrome do |app|
  options = Selenium::WebDriver::Chrome::Options.new(
    args: [
      'headless=new',
      'no-sandbox',
      '--window-size=2560,1440',
      '--disable-web-security',
      '--allow-running-insecure-content',
      "--enable-logging", # Enables logging
      "--log-level=0", # Enables all logging
      "--v=1" # Sets the verbosity level of logging
    ]
  )

  options.add_option('goog:loggingPrefs', { browser: 'ALL' })

  Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

目前无法定位这些无效请求的来源,想知道如何消除该问题或进行调试?

更新情况

问题仍未解决,且将Chromedriver从127版本升级至128版本后问题复现。若将配置中args参数改为headless=old可消除上述报错,但首次功能测试会出现This site can't be reached的错误。


内容的提问来源于stack exchange,提问作者Rodrigo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 20:35:22