[英]How to fix "Selenium::WebDriver::Error::WebDriverError: chrome not reachable" in WSL2
I am trying to use WSL2 to rails application and had this error when RSpec is running:我正在尝试将 WSL2 用于 Rails 应用程序,并在 RSpec 运行时出现此错误:
Selenium::WebDriver::Error::WebDriverError:
chrome not reachable
(Session info: headless chrome=77.0.3865.75)
Someone know to fix it?有人知道修吗?
My capybara.rb:我的水豚.rb:
require "capybara/rails"
require "selenium-webdriver"
Capybara.default_max_wait_time = 10
Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w[headless no-sandbox]
)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Capybara.javascript_driver = :chrome
Capybara.server = :puma, { Silent: true }
I put the path in env variables to reach my chromewebdriver binary, following this article " https://ngauthier.com/2017/09/rails-system-tests-with-headless-chrome-on-windows-bash-wsl.html " and nothing!我将路径放在 env 变量中以到达我的 chromewebdriver 二进制文件,按照这篇文章“ https://ngauthier.com/2017/09/rails-system-tests-with-headless-chrome-on-windows-bash-wsl.html “ 没事了!
I just fix it with the following code我只是用下面的代码修复它
Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(args: %w[
headless no-sandbox disable-gpu window-size=1920x1080
])
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: {
"chromeOptions" => {
w3c: false
}
}
)
end
Please let me know if this is resolve your issue请让我知道这是否可以解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.