RSpec Rails 测试 - 警告 Selenium [弃用] 和 TypeError:没有将 nil 隐式转换为 String

问题描述 投票:0回答:1

开始使用 Rails 测试并遵循 本教程.

当我用 rspec spec/hello_world.rb 运行第一个测试时

我收到以下错误:

WARN Selenium [弃用] [:capabilities] Selenium::WebDriver::Chrome::Driver 的 :capabilities 参数已弃用。将 :options 参数与 Selenium::WebDriver::Chrome::Driver 的实例一起使用。

失败:

  1. Hello World 索引页面显示正确的内容 有 0 次失败和 2 次其他错误:

    1.1) 失败/错误:访问 hello_world_index_path

     TypeError:
       no implicit conversion of nil into String
     # ./spec/hello_world_spec.rb:9:in `block (3 levels) in <top (required)>'
    

    1.2) 失败/错误:@pid = Process.spawn(*@command, options)

     TypeError:
       no implicit conversion of nil into String
    

堆栈跟踪显示:ruby/gems/3.1.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/child_process.rb:57:in `spawn'

我正在使用最新的网络驱动程序和 selenium-webdriver。

我在 m1 macbook 上找到了这个解决方案来更新我的 chrome-drivers 但它仍然导致相同的错误。

我现在没有想法,甚至无法开始学习如何使用 Rails 进行测试,因此非常感谢任何帮助。

ruby-on-rails ruby selenium-webdriver rspec webdrivers-gem
1个回答
0
投票

错误是bug。据报道这里 https://github.com/SeleniumHQ/selenium/issues/11815 并将在下一个版本中修复。如果将 Selenium 降级到 4.8.1,一切都会按预期工作。

弃用通知是关于如何将功能传递给 Selenium 的。不幸的是,Watir 和 Capybara 都使用旧方法传递内容,因此需要在这些项目中修复它。 (在我弃用 Selenium 中的这种方法之前,我可能应该在旧项目中修复它们)。

如果您想避免在您的控制台中看到该弃用通知,您可以将其添加到您的代码中:

Selenium::WebDriver.logger.ignore :capabilities
© www.soinside.com 2019 - 2024. All rights reserved.