jejacks0n / teaspoon

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

allow passing selenium options #537

Closed odedniv closed 5 years ago

odedniv commented 6 years ago

Chrome now allows headless capability, but teaspoon stood between my app and the ability to use it. Here's the fix, and this is how I use it in my spec/teaspoon_env.rb (I recommend adding it to the wiki):

Teaspoon.configure do |config|
  config.driver_options = {
    client_driver: :chrome,
    selenium_options: {
      options: Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu'])
    }
  }
end

To my understanding PhantomJS ceased development because of overwhelming security issues, and the fact it can be replaced by Chrome's headless capability. I think it's time to replace it with Selenium as the default driver.

jejacks0n commented 6 years ago

Agree with your points about phantom being deprecated. It's been on my list of things to get to -- I would accept a PR that effectively removes phantomjs and makes the chrome driver primary, otherwise I'd rather wait to pull this in to avoid two passes at trying to resolve this.

odedniv commented 6 years ago

Is the way I passed the options reasonable? If so I don't see why this PR cannot be merged regardless of changing the default.

I'm assuming you refer to the docs and the generator? Or do you want to remove support? That would be a hurtful breaking change (that may delay this little change unnecessarily)

If you'd lay out exactly what you want done (e.g. do you want to change the default to what I wrote above? do you want to add documentation in the wiki and the generator? etc) I'd be happy to push a PR (though I don't know where the wiki is or the generator).

bmulholland commented 6 years ago

@jejacks0n There's a few other PRs to do the same thing (https://github.com/jejacks0n/teaspoon/pull/519, https://github.com/jejacks0n/teaspoon/pull/530), perhaps there's enough demand to merge (one of) this change on its own?

josh08h commented 6 years ago

Is there any movement on this? I am looking at migrating off phantomjs onto headless chrome but obviously need this change in.

odedniv commented 6 years ago

@josh08h until the maintainer gets a chance to work on it, you can use the branch directly (I have ever since I opened this PR). In your Gemfile:

  gem 'teaspoon', github: 'odedniv/teaspoon', branch: 'selenium-options'

You can fork and use your own branch if you're intimidated by doing that.

The only problem I had with using Chrome is that console.log no longer appears in the terminal, I have to stop using headless mode and open the inspect element window to see them.

josh08h commented 6 years ago

Thanks for the heads up re console.log.

Your patch looks good to me - I'll most likely fork off your branch.

jejacks0n commented 6 years ago

If y’all can figure out why console log doesn’t work I’ll merge this.

odedniv commented 6 years ago

@jejacks0n I think it's still better than using a deprecated driver :) Also this PR doesn't break anything, it just allows additional driver options (whatever driver you happen to use)

pjmelling commented 5 years ago

@odedniv and @jejacks0n Thanks for the work on this! I would love to see this merged in. We are using headless FF in our CI environment for our ruby based feature specs. And I want to ditch PhantomJS and use headless FF for teaspoon, too. Is there something holding this back that I could help with? Thanks!

jejacks0n commented 5 years ago

@pjmelling would you be willing to sort out CI? IT's pretty hard to merge when CI is broken and I simply haven't had time to work on open source much in the past year or two.

pablobm commented 5 years ago

https://github.com/jejacks0n/teaspoon/pull/552 fixes the build. Perhaps we can proceed to merge this? :-) /cc @odedniv @jejacks0n

jejacks0n commented 5 years ago

I’m mobile, anybody want to rebase and check things?

odedniv commented 5 years ago

Done, seem to work

odedniv commented 5 years ago

Oops, if anyone was using my PR branch (including me), your Gemfile.lock is now broken (fatal: Could not parse object 'f64781ee6097e18fb838bc4fd5725172e3a24d27').

Run bundle update --source teaspoon to fix