简体   繁体   English

如何修复 WSL2 中的“Selenium::WebDriver::Error::WebDriverError: chrome notreachable”

[英]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.

相关问题 无法连接到chromedriver http://127.0.0.1:9515(Selenium :: WebDriver :: Error :: WebDriverError) - unable to connect to chromedriver http://127.0.0.1:9515 (Selenium::WebDriver::Error::WebDriverError) Rails:Selenium :: WebDriver :: Error :: WebDriverError:不可执行:'chromedriver-helper' - Rails: Selenium::WebDriver::Error::WebDriverError: not executable: 'chromedriver-helper' Heroku/Rails 上的 Chromedriver:无法加载应用程序:Selenium::WebDriver::Error::WebDriverError:不是文件:“/usr/local/bin/chromedriver” - Chromedriver on Heroku/Rails: Unable to load application: Selenium::WebDriver::Error::WebDriverError: not a file: "/usr/local/bin/chromedriver" Ruby - 无法在 45 秒内绑定到锁定端口 7054 (Selenium::WebDriver::Error::WebDriverError) - Ruby - unable to bind to locking port 7054 within 45 seconds (Selenium::WebDriver::Error::WebDriverError) Gitlab-CI Selenium::WebDriver::Error::WebDriverError: 无法连接到 chromedriver 127.0.0.1:9515 - Gitlab-CI Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver 127.0.0.1:9515 运行rake spec错误时Selenium :: WebDriver :: Error :: WebDriverError:无法在60秒内获得稳定的firefox连接(127.0.0.1:7055) - while running rake spec error Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) 如何在Amazon Linux上使用带有chrome驱动程序的selenium。 错误:Selenium :: WebDriver :: Error :: UnknownError:未知错误:找不到Chrome二进制文件 - How to use selenium with chrome driver on Amazon Linux. error: Selenium::WebDriver::Error::UnknownError: unknown error: cannot find Chrome binary 如何访问 cookies(Capybara/Selenium Chrome Webdriver) - How to access cookies (Capybara/Selenium Chrome Webdriver) WSL2 和 PostgreSQL 连接 - WSL2 and PostgreSQL connection Selenium Webdriver Zoom with Ruby for Chrome - Selenium webdriver zoom with Ruby for Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM