开始使用 Rails 测试并遵循 本教程.
当我用 rspec spec/hello_world.rb 运行第一个测试时
我收到以下错误:
WARN Selenium [弃用] [:capabilities] Selenium::WebDriver::Chrome::Driver 的 :capabilities 参数已弃用。将 :options 参数与 Selenium::WebDriver::Chrome::Driver 的实例一起使用。
和
失败:
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 进行测试,因此非常感谢任何帮助。
错误是bug。据报道这里 https://github.com/SeleniumHQ/selenium/issues/11815 并将在下一个版本中修复。如果将 Selenium 降级到 4.8.1,一切都会按预期工作。
弃用通知是关于如何将功能传递给 Selenium 的。不幸的是,Watir 和 Capybara 都使用旧方法传递内容,因此需要在这些项目中修复它。 (在我弃用 Selenium 中的这种方法之前,我可能应该在旧项目中修复它们)。
如果您想避免在您的控制台中看到该弃用通知,您可以将其添加到您的代码中:
Selenium::WebDriver.logger.ignore :capabilities