jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Can not pass --headless option to selenium firefox driver #570

Closed thebravoman closed 3 years ago

thebravoman commented 4 years ago

Tests are running successfully in browser and on CLI by opening a browser.

Trying to run the specs with selenim driver, headless

config is

  config.driver = :selenium

   config.driver_options = {
    client_driver: :firefox,
    selenium_options: {
      options: Selenium::WebDriver::Firefox::Options.new(args: ['--headless'])
    }
   }

Tried also

 options: Selenium::WebDriver::Firefox::Options.new(args: ['headless'])

The firefox browser is opened in both cases.

The following configuration works for another gem on the same machine so I would assume the driver is generally working on this machine.

Capybara.register_driver :firefox_headless do |app|
    options = ::Selenium::WebDriver::Firefox::Options.new
    options.args << '--headless'

    Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
  end

  Capybara.javascript_driver = :firefox_headless
mathieujobin commented 3 years ago

Can you open a PR with the suggested change?

thank you

mathieujobin commented 3 years ago

works for me, tests run in firefox headless locally and on CI browser window is not opening when using headless see 805523c55eb0 for details