ruby-on-rails 尝试在Heroku RoR上使用 selenium 时出现'connect_until_stable'错误

8cdiaqws  于 2023-02-17  发布在  Ruby
关注(0)|答案(1)|浏览(89)

我试图运行一个关于Heroku的含有 selenium 的文件。但是,我得到了下面的错误。

/app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/service_manager.rb:130:in `connect_until_stable': unable to connect to /app/.cache/selenium/chromedriver/linux64/109.0.5414.74/chromedriver 127.0.0.1:9515 (Selenium::WebDriver::Error::WebDriverError)
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/service_manager.rb:57:in `block in start'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/socket_lock.rb:41:in `locked'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/service_manager.rb:54:in `start'
        from <internal:kernel>:90:in `tap'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/service.rb:83:in `launch'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/driver.rb:341:in `service_url'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/driver.rb:321:in `create_bridge'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/driver.rb:74:in `initialize'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/driver.rb:47:in `new'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver/common/driver.rb:47:in `for'
        from /app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.7.1/lib/selenium/webdriver.rb:88:in `for'
        from bin/flights_data.rb:22:in `scraper'
        from bin/flights_data.rb:36:in `<main>'

我不知道这个错误是什么意思。我同时安装了chromedriver和chrome构建包。我在gem文件中列出了selenium。

gem文件

gem 'selenium-webdriver'

测试Ruby文件

selenium

def selenium
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_argument('--headless')
    driver = Selenium::WebDriver.for :chrome, options: options
    puts "HELLO"
    open_google(driver)
end

def open_google(driver)
    driver.get 'https://www.google.com/flights'
end

Can someone help explain the error?

mzillmmw

mzillmmw1#

我需要在Heroku上添加Chrome驱动程序并运行重启服务器。

相关问题