Skip to content

Commit

Permalink
Omit webdrivers gem from Gemfile template
Browse files Browse the repository at this point in the history
As of Selenium 4.6, [the Selenium Manager is capable of managing Chrome
Driver installations and integrations][readme]. As of Selenium 4.11, the
Selenium Manager is capable of [capable of resolving the Chrome for
Testing installation][] path.

By omitting the `gem` declaration from the `Gemfile.tt`, newly generated
applications and applications updating their `Gemfile` in lockstep with
newer Rails versions can shed the dependency and avoid test failures
introduced by newly released Chrome versions (like, for example,
[titusfortner/webdrivers#247][]).

[readme]: https://github.com/titusfortner/webdrivers/tree/43f8ac436cc4121c903c1c611dfe76088ef6cbab#update-selenium-manager
[titusfortner/webdrivers#247]: titusfortner/webdrivers#247
[capable of resolving the Chrome for Testing installation]: #48847 (comment)

Co-authored-by: Titus Fortner <titusfortner@users.noreply.github.com>
  • Loading branch information
seanpdoyle and titusfortner committed Aug 1, 2023
1 parent 35a614c commit 9a53234
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 31 deletions.
8 changes: 2 additions & 6 deletions Gemfile
Expand Up @@ -14,8 +14,8 @@ gem "rake", ">= 13"

gem "sprockets-rails", ">= 2.0.0"
gem "propshaft", ">= 0.1.7"
gem "capybara", ">= 3.38"
gem "selenium-webdriver", ">= 4.0.0"
gem "capybara", ">= 3.39"
gem "selenium-webdriver", ">= 4.11.0"

gem "rack-cache", "~> 1.2"
gem "stimulus-rails"
Expand Down Expand Up @@ -121,10 +121,6 @@ end
gem "aws-sdk-sns", require: false
gem "webmock"

group :ujs do
gem "webdrivers"
end

# Add your own local bundler stuff.
local_gemfile = File.expand_path(".Gemfile", __dir__)
instance_eval File.read local_gemfile if File.exist? local_gemfile
Expand Down
13 changes: 4 additions & 9 deletions Gemfile.lock
Expand Up @@ -158,7 +158,7 @@ GEM
bunny (2.20.2)
amq-protocol (~> 2.3, >= 2.3.1)
sorted_set (~> 1, >= 1.0.2)
capybara (3.38.0)
capybara (3.39.2)
addressable
matrix
mini_mime (>= 0.1.3)
Expand Down Expand Up @@ -457,7 +457,7 @@ GEM
fugit (~> 1.1, >= 1.1.6)
sdoc (2.6.1)
rdoc (>= 5.0)
selenium-webdriver (4.7.1)
selenium-webdriver (4.11.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -532,10 +532,6 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down Expand Up @@ -565,7 +561,7 @@ DEPENDENCIES
bcrypt (~> 3.1.11)
benchmark-ips
bootsnap (>= 1.4.4)
capybara (>= 3.38)
capybara (>= 3.39)
cgi (>= 0.3.6)
connection_pool
cssbundling-rails
Expand Down Expand Up @@ -616,7 +612,7 @@ DEPENDENCIES
rubocop-rails
rubyzip (~> 2.0)
sdoc (>= 2.6.0)
selenium-webdriver (>= 4.0.0)
selenium-webdriver (>= 4.11.0)
sidekiq
sneakers
sprockets-rails (>= 2.0.0)
Expand All @@ -632,7 +628,6 @@ DEPENDENCIES
w3c_validators (~> 1.3.6)
wdm (>= 0.1.0)
web-console
webdrivers
webmock
webrick
websocket-client-simple!
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/system_testing/browser.rb
Expand Up @@ -26,7 +26,7 @@ def configure
yield options if block_given? && options
end

# driver_path can be configured as a proc. The webdrivers gem uses this
# driver_path can be configured as a proc.
# proc to update web drivers. Running this proc early allows us to only
# update the webdriver once and avoid race conditions when using
# parallel tests.
Expand Down
10 changes: 0 additions & 10 deletions guides/source/testing.md
Expand Up @@ -886,16 +886,6 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
end
```

In such a case, the gem `webdrivers` is no longer required. You could remove it
completely or add `require:` option in `Gemfile`.

```ruby
# ...
group :test do
gem "webdrivers", require: !ENV["SELENIUM_REMOTE_URL"] || ENV["SELENIUM_REMOTE_URL"].empty?
end
```

Now you should get a connection to remote browser.

```bash
Expand Down
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
@@ -1,3 +1,7 @@
* Omit `webdrivers` gem dependency from `Gemfile` template

*Sean Doyle*

* Support filtering tests by line ranges

The new syntax allows you to filter tests by line ranges. For example, the
Expand Down
5 changes: 2 additions & 3 deletions railties/lib/rails/generators/rails/app/templates/Gemfile.tt
Expand Up @@ -59,8 +59,7 @@ end
<%- if depends_on_system_test? -%>
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem "capybara", ">= 3.39"
gem "selenium-webdriver", ">= 4.11.0"
end
<%- end -%>
2 changes: 0 additions & 2 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -532,7 +532,6 @@ def test_generator_if_skip_test_is_given

assert_no_gem "capybara"
assert_no_gem "selenium-webdriver"
assert_no_gem "webdrivers"

assert_no_directory("test")
end
Expand All @@ -559,7 +558,6 @@ def test_generator_if_skip_system_test_is_given
run_generator [destination_root, "--skip-system-test"]
assert_no_gem "capybara"
assert_no_gem "selenium-webdriver"
assert_no_gem "webdrivers"

assert_directory("test")

Expand Down

0 comments on commit 9a53234

Please sign in to comment.