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

Move away from PhantomJS as default? #545

Open
rmm5t opened this issue Sep 10, 2018 · 10 comments
Open

Move away from PhantomJS as default? #545

rmm5t opened this issue Sep 10, 2018 · 10 comments
Labels

Comments

@rmm5t
Copy link

rmm5t commented Sep 10, 2018

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

@jejacks0n
Copy link
Owner

Yes, for sure.

@jejacks0n
Copy link
Owner

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

@thbar
Copy link

thbar commented Sep 24, 2018

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.

@teeparham
Copy link

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

@mathias
Copy link

mathias commented Nov 13, 2018

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'

@joshm1204
Copy link

joshm1204 commented May 9, 2019

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.

@rmm5t
Copy link
Author

rmm5t commented May 9, 2019

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

@joshm1204
Copy link

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?

@rmm5t
Copy link
Author

rmm5t commented May 9, 2019

@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 } }

@la-ruby
Copy link

la-ruby commented Apr 18, 2020

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),
      ),
    },
  }

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

No branches or pull requests

8 participants