twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

Errno::ECONNREFUSED:Connection refused #54

Closed smith558 closed 3 years ago

smith558 commented 4 years ago

Getting exception Errno::ECONNREFUSED:Connection refused - connect(2) for "127.0.0.1" port 55031 when running RSPEC examples with Capybara using Apparition driver. Selenium works just fine. Port changes with each run, fails the same way.

Ubuntu 18.04 WSL 1 ChromeDriver 81.0.4044.138

twalpole commented 4 years ago

Sounds like your chromedriver or chrome is failing to run

smith558 commented 4 years ago

@twalpole selenium-webdriver on the same configuration works just fine, but I'd like to run Apparition rather (Chrome installed on Windows, added to PATH and .bashrc, chromedriver installed on Windows added to PATH and and .bashrc)

I am using WSL 1 and trying to run headless.

Apparition configuration:

Capybara.register_driver :apparition do |app|
  Capybara::Apparition::Driver.new(app,
    url_blacklist: ['fonts.googleapis.com'],
    js_errors: false,
    browser_logger: nil,
    headless: true,
    browser_options: [:disable_gpu, :no_sandbox, disable_features: 'VizDisplayCompositor'])
end
Capybara.javascript_driver = :apparition

console output when fails: rspec -fd spec/features/xxxxx_spec.rb

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 36689

Xxxxxxxxxxxx
Capybara starting Puma...
* Version 3.12.4 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:59890
  xxxxxxxxxxxxxxxxxxxxx (FAILED - 1)

Failures:

  1) Xxxxxxxxxxxx
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: visit xxxxxxxx_path

          Errno::ECONNREFUSED:
            Connection refused - connect(2) for "127.0.0.1" port 59896
          # ./spec/features/xxxxx_spec.rb:in `block (2 levels) in <top (required)>'
          # ./spec/support/database_shared_connection.rb:29:in `block (2 levels) in <top (required)>'

RSPEC database specific configuration utility: database_shared_connection.rb

RSpec.configure do |config|
  config.around(:each) do |example|
    if example.metadata[:js] || example.metadata[:driver]
      ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
      SecondBase::Base.second_base_shared_connection = SecondBase::Base.connection
      example.run
      ActiveRecord::Base.shared_connection = nil
      SecondBase::Base.second_base_shared_connection = nil
    else
      example.run
    end
  end
end

Thanks for your assistance!

twalpole commented 4 years ago

I don’t have a windows machine currently so apparition may not know how to find Chrome on your configuration. PRs welcome

smith558 commented 3 years ago

Moved to an alternative.