From 0b2659cc509e03c617bed36e7c8b655a2a3d2716 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 11 Aug 2023 08:28:26 -0700 Subject: [PATCH 1/2] :gear: this commit addresses a deprecated pattern for Selenium desired_capabilities is deprecated. This commit changes the way we initialize selenium driver per the newer requirements when dual booting. At this point, it resolves the error how there are still local timeout issues. ref: - https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/remote/driver.rb#L32 Issue: - https://github.com/scientist-softserv/ams/issues/64 --- spec/rails_helper.rb | 49 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f407ce1d..6d3abfe5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -43,23 +43,42 @@ if ENV['CHROME_HOSTNAME'].present? Capybara.default_max_wait_time = 8 - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { - args: %w[disable-gpu no-sandbox whitelisted-ips window-size=1400,1400] - } - ) + if App.rails_5_1? + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( + chromeOptions: { + args: %w[disable-gpu no-sandbox whitelisted-ips window-size=1400,1400] + } + ) - Capybara.register_driver :chrome do |app| - d = Capybara::Selenium::Driver.new(app, - browser: :remote, - desired_capabilities: capabilities, - url: "http://#{ENV['CHROME_HOSTNAME']}:4444/wd/hub") - # Fix for capybara vs remote files. Selenium handles this for us - d.browser.file_detector = lambda do |args| - str = args.first.to_s - str if File.exist?(str) + Capybara.register_driver :chrome do |app| + d = Capybara::Selenium::Driver.new(app, + browser: :remote, + desired_capabilities: capabilities, + url: "http://#{ENV['CHROME_HOSTNAME']}:4444/wd/hub") + # Fix for capybara vs remote files. Selenium handles this for us + d.browser.file_detector = lambda do |args| + str = args.first.to_s + str if File.exist?(str) + end + d + end + else + chrome_options = Selenium::WebDriver::Chrome::Options.new( + args: %w[--disable-gpu --no-sandbox --whitelisted-ips --window-size=1400,1400] + ) + + Capybara.register_driver :chrome do |app| + d = Capybara::Selenium::Driver.new(app, + browser: :remote, + options: chrome_options, + url: "http://#{ENV['CHROME_HOSTNAME']}:4444/wd/hub") + # Fix for capybara vs remote files. Selenium handles this for us + d.browser.file_detector = lambda do |args| + str = args.first.to_s + str if File.exist?(str) + end + d end - d end Capybara.server_host = '0.0.0.0' Capybara.server_port = 3001 From 8c69a372033b5495527e5e9515eef1e0b0eb53ea Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 11 Aug 2023 10:09:14 -0700 Subject: [PATCH 2/2] :gear: fix unblocks devs from running feature specs locally This change allowed feature specs to run locally. I am not sure why this fixed things or why we are even able to connect to hyku.test so this may be a smell and something to dive into later. For now it unblocks devs though! --- docker-compose.yml | 2 +- spec/rails_helper.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index eeff9a39..5cf690a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -235,4 +235,4 @@ services: environment: - JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps= - VIRTUAL_PORT=7900 - - VIRTUAL_HOST=chrome.ams.test + - VIRTUAL_HOST=chrome.hyku.test diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6d3abfe5..2ec4e5fc 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -41,7 +41,9 @@ ENV['WEB_HOST'] ||= `hostname -s`.strip if ENV['CHROME_HOSTNAME'].present? + # Uses faster rack_test driver when JavaScript support not needed Capybara.default_max_wait_time = 8 + # Capybara.default_driver = :rack_test if App.rails_5_1? capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(