teaspoon icon indicating copy to clipboard operation
teaspoon copied to clipboard

Move away from PhantomJS as default?

Open rmm5t opened this issue 6 years ago • 10 comments

With the PhantomJS project abandoned, and potential issues with teaspoon + phantomjs, should teaspoon change it's default driver to something else?

rmm5t avatar Sep 10 '18 14:09 rmm5t

Yes, for sure.

jejacks0n avatar Sep 10 '18 18:09 jejacks0n

I think we should just build out the selenium setup, specifically focusing on chromedriver.

jejacks0n avatar Sep 10 '18 18:09 jejacks0n

I second that - on a client's project, the build started failing on CircleCI, I think because PhantomJS was moved to "legacy" (https://circleci.com/docs/2.0/circleci-images/#language-image-variants). I suspect we'll see more of that in the future on other cases.

thbar avatar Sep 24 '18 08:09 thbar

For reference, to switch to selenium + chromedriver:

# Gemfile
group :test do
  gem "selenium-webdriver"
end

# teaspoon_env.rb
Teaspoon.configure do |config|
  config.driver = :selenium
  config.driver_options = { client_driver: :chrome }
end

teeparham avatar Sep 27 '18 15:09 teeparham

I seem to be caught in a Catch-22 in using Chrome with selenium-webdriver, though.

If I have the gem gem "chromedriver-helper" in my Gemfile, then I can run my Capybara acceptance tests in Rspec. But Teaspoon doesn't like it.

Teaspoon running default suite at http://127.0.0.1:64564/teaspoon/default
bundler: failed to load command: teaspoon (/Users/mgauger/.rbenv/versions/2.5.1/bin/teaspoon)
Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver 127.0.0.1:9515
  /Users/mgauger/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.14.1/lib/selenium/webdriver/common/service.rb:142:in `connect_until_stable'

If I remove the gem "chromedriver-helper" in the Gemfile, it finds the system Chromedriver (installed with Brew on this mac) and ~runs the Teaspoon suite.~ But Capybara tests fail with errors like:

     Failure/Error: visit '/page'

     Selenium::WebDriver::Error::WebDriverError:
       unable to connect to chromedriver 127.0.0.1:9515

Has anyone else run into this?

Edit: I was wrong above. It isn't actually running my Teaspoon suite in either situation. I also tried this fork to pass in the same Selenium arguments as my Capybara suite gets: gem 'teaspoon', github: 'odedniv/teaspoon', branch: 'selenium-options'

mathias avatar Nov 13 '18 15:11 mathias

Has anyone looked into headless browsers? I reference this article and would love feedback on if this is a good direction to go. I am new to Teaspoon, so not sure.

https://www.puzzle.ch/de/blog/articles/2018/02/12/phantomjs-is-dead-long-live-headless-browsers

As Karma sounded interesting.

joshm1204 avatar May 09 '19 14:05 joshm1204

@joshm1204 I think the suggested default approach here would be "Alternative 2" in the article you referenced.

rmm5t avatar May 09 '19 14:05 rmm5t

Yes, I think a chrome's headless browser for example would be a good solution. Is there any ability to use Chrome's headless browser yet?

joshm1204 avatar May 09 '19 16:05 joshm1204

@joshm1204 In addition to either using chromedriver-helper gem (deprecated) or webdrivers gem (replacement) and configuring the chromedriver version, you can do something like this inside the teaspoon_env.rb:

  config.driver = :selenium

  options = ::Selenium::WebDriver::Chrome::Options.new(args: ["--no-sandbox"])
  options.headless!
  config.driver_options = { client_driver: :chrome, client_driver_opts: { options: options } }

rmm5t avatar May 09 '19 22:05 rmm5t

i'm using a modified version of ^ snippet to, like solidus does at solidus/backend/spec/teaspoon_env.rb. otherwise a chrome window appears , which shouldn't if it was truly headless.

  config.driver = :selenium
  config.driver_options = {
    client_driver: :chrome,
    selenium_options: {
      options: Selenium::WebDriver::Chrome::Options.new(
        args: %w(headless disable-gpu window-size=1920,1440),
      ),
    },
  }

la-ruby avatar Apr 18 '20 13:04 la-ruby