Skip to content

Commit

Permalink
Manage Selenium drivers automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Dec 28, 2021
1 parent ceae954 commit cf82a88
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ group :test do
gem "selenium-webdriver"
gem "shoulda-matchers"
gem "timecop"
gem "webdrivers"
gem "webmock"
gem "xpath", "3.2.0"
end
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ GEM
unicorn (6.0.0)
kgio (~> 2.6)
raindrops (~> 0.7)
webdrivers (5.0.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webmock (3.14.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down Expand Up @@ -352,6 +356,7 @@ DEPENDENCIES
timecop
uglifier
unicorn
webdrivers
webmock
xpath (= 3.2.0)
yard
Expand Down
5 changes: 0 additions & 5 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ bundle exec rake db:setup dev:prime
# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
mkdir -p .git/safe

if ! command -v chromedriver > /dev/null; then
printf 'chromedriver is not installed.\n'
printf 'See https://chromedriver.chromium.org for install instructions.\n'
fi

# Only if this isn't CI
# if [ -z "$CI" ]; then
# fi
4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "webmock/rspec"

# http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
Expand All @@ -12,5 +10,3 @@

config.order = :random
end

WebMock.disable_net_connect!(allow_localhost: true)
11 changes: 11 additions & 0 deletions spec/support/webmock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "webmock/rspec"

# Allow downloading webdrivers for Selenium
driver_hosts = Webdrivers::Common.subclasses.
map { |driver| URI(driver.base_url).host }

# Downloading the Firefox driver involves a redirect
driver_hosts += ["github-releases.githubusercontent.com"]

# Additionally, avoid conflict with Selenium (localhost)
WebMock.disable_net_connect!(allow_localhost: true, allow: driver_hosts)

0 comments on commit cf82a88

Please sign in to comment.