Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capybara cannot configure Firefox #2766

Open
adeherdt-r7 opened this issue Jul 10, 2024 · 3 comments
Open

Capybara cannot configure Firefox #2766

adeherdt-r7 opened this issue Jul 10, 2024 · 3 comments

Comments

@adeherdt-r7
Copy link

Meta

Capybara Version: 3.40.0
Driver Information (and browser if relevant):

  • selenium-webdriver: 4.10.0
  • Firefox: 128.0 (Snap Installation)

Expected Behavior

  • Tests written with Cucumber and Capybara should work

Actual Behavior

Tests crash during Capybara configuration:

Selenium::WebDriver::Error::UnknownError: Process unexpectedly closed with status 127
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/response.rb:55:in `assert_ok'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/bridge.rb:620:in `execute'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/bridge.rb:53:in `create_session'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/driver.rb:317:in `block in create_bridge'
<internal:kernel>:90:in `tap'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/driver.rb:316:in `create_bridge'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/driver.rb:74:in `initialize'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/firefox/driver.rb:43:in `initialize'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/driver.rb:53:in `new'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/driver.rb:53:in `for'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver.rb:88:in `for'
/home/noel/.rvm/gems/ruby-3.1.4@pro/gems/capybara-3.40.0/lib/capybara/selenium/driver.rb:75:in `browser'
/home/noel/RubymineProjects/pro/ui/features/support/hooks/browser.rb:3:in `Before'

The before block:

Before('not @json') do
  Capybara.reset_sessions!
  Capybara.current_session.driver.browser.manage.window.resize_to(1920, 1050)
  if TestConfig.instance.video_capture
    TestConfig.instance.headless.video.start_capture
  end
end

Steps to reproduce

  • Ruby on Rails project
  • Capybara
  • Firefox installation using Ubuntu Snap
  • Setup before block
  • run a test
@twalpole
Copy link
Member

Seems like you're trying to set the window size on a non-existent session

@adeherdt-r7
Copy link
Author

Seems like you're trying to set the window size on a non-existent session

The issue is snap.
This is Firefox installed through snap, and Capybara is unable to work with it.
Standalone installations seem to work fine.

@bogn83
Copy link

bogn83 commented Nov 14, 2024

I tried the different combinations that snap installs since /usr/bin/firefox is just a wrapper to start these with snap:

/snap/bin/firefox
/snap/bin/firefox.geckodriver
/snap/bin/geckodriver

The only one that worked to get past the not a firefox binary error was '/snap/bin/firefox'

options = Selenium::WebDriver::Firefox::Options.new
options.binary = '/snap/bin/firefox'
service = Selenium::WebDriver::Service.firefox
service.executable_path = options.binary
puts "!!! #{`ls -l #{options.binary}`}"
driver = Selenium::WebDriver.for :firefox, service: service, options: options
Capybara.current_driver = driver

While this gets me past the binary path not found errors and opens a firefox, I still get:

Selenium::WebDriver::Error::WebDriverError:
  unable to connect to /snap/bin/firefox 127.0.0.1:4507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants