File tree 6 files changed +60
-8
lines changed
6 files changed +60
-8
lines changed Original file line number Diff line number Diff line change @@ -96,5 +96,4 @@ group :test do
96
96
gem "webmock"
97
97
gem "capybara"
98
98
gem "selenium-webdriver" , "~> 4.11.0"
99
- gem "webdrivers"
100
99
end
Original file line number Diff line number Diff line change 518
518
activemodel (>= 6.0.0 )
519
519
bindex (>= 0.4.0 )
520
520
railties (>= 6.0.0 )
521
- webdrivers (5.2.0 )
522
- nokogiri (~> 1.6 )
523
- rubyzip (>= 1.3.0 )
524
- selenium-webdriver (~> 4.0 )
525
521
webmock (3.25.1 )
526
522
addressable (>= 2.8.0 )
527
523
crack (>= 0.3.2 )
@@ -598,7 +594,6 @@ DEPENDENCIES
598
594
tzinfo-data
599
595
validate_url
600
596
web-console
601
- webdrivers
602
597
webmock
603
598
604
599
BUNDLED WITH
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # This script checks if any tests in the project need chromedriver
3
+ # and runs the install script if needed
4
+
5
+ require "pathname"
6
+
7
+ APP_ROOT = File . expand_path ( ".." , __dir__ )
8
+
9
+ def check_for_js_tests
10
+ js_test_present = false
11
+
12
+ Dir . glob ( "#{ APP_ROOT } /spec/**/*_spec.rb" ) . each do |file |
13
+ content = File . read ( file )
14
+ if content . match ( /js:\s *true/ )
15
+ js_test_present = true
16
+ break
17
+ end
18
+ end
19
+
20
+ js_test_present
21
+ end
22
+
23
+ def chromedriver_installed?
24
+ system ( "which chromedriver > /dev/null 2>&1" )
25
+ end
26
+
27
+ # First, check if we need chromedriver for our tests
28
+ if check_for_js_tests
29
+ # Next, check if chromedriver is already installed
30
+ if chromedriver_installed?
31
+ puts "\n == JavaScript tests found, but chromedriver is already installed. Skipping installation. =="
32
+ else
33
+ puts "\n == JavaScript tests found and chromedriver not detected. Running installation... =="
34
+ system "bin/chromedriver_install"
35
+ end
36
+ else
37
+ puts "\n == No JavaScript tests found, skipping chromedriver installation =="
38
+ end
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Script to install Chrome and matching chromedriver at the system level for Linux
3
+ # This script is called by chromedriver_check when JS tests are detected
4
+
5
+ set -euo pipefail
6
+
7
+ sudo apt-get update -y
8
+
9
+ CHROME_DRIVER_VERSION=128.0.6613.137
10
+ CHROME_PATH=" /usr/local/chrome"
11
+ CHROMEDRIVER_PATH=" /usr/local/chromedriver"
12
+ sudo mkdir -p " $CHROME_PATH " " $CHROMEDRIVER_PATH "
13
+
14
+ # Install Chrome and Chromedriver
15
+ echo " y" | sudo npx @puppeteer/browsers install chrome@${CHROME_DRIVER_VERSION} --install-deps --path=" $CHROME_PATH "
16
+ echo " y" | sudo npx @puppeteer/browsers install chromedriver@${CHROME_DRIVER_VERSION} --path=" $CHROMEDRIVER_PATH "
17
+
18
+ sudo ln -sf ${CHROME_PATH} /linux-${CHROME_DRIVER_VERSION} /chrome-linux64/chrome /usr/local/bin/google-chrome
19
+ sudo ln -sf ${CHROMEDRIVER_PATH} /linux-${CHROME_DRIVER_VERSION} /chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
Original file line number Diff line number Diff line change @@ -30,4 +30,7 @@ FileUtils.chdir APP_ROOT do
30
30
31
31
puts "\n == Removing old logs and tempfiles =="
32
32
system! "bin/rails log:clear tmp:clear"
33
+
34
+ puts "\n == Checking for JavaScript tests and installing chromedriver if needed =="
35
+ system! "bin/chromedriver_check"
33
36
end
Original file line number Diff line number Diff line change 1
- require "webdrivers/chromedriver"
2
-
3
1
Capybara . register_driver :headless_chrome do |app |
4
2
options = Selenium ::WebDriver ::Chrome ::Options . new
5
3
options . add_argument ( "--headless" )
You can’t perform that action at this time.
0 commit comments