Skip to content

Commit

Permalink
Merge pull request #750 from WGBH-MLA/i64-resolve-selenium-error
Browse files Browse the repository at this point in the history
⚙️ [i32] - resolve selenium error
  • Loading branch information
ShanaLMoore authored Aug 11, 2023
2 parents 187f1a1 + 8c69a37 commit d58bde0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,4 @@ services:
environment:
- JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
- VIRTUAL_PORT=7900
- VIRTUAL_HOST=chrome.ams.test
- VIRTUAL_HOST=chrome.hyku.test
51 changes: 36 additions & 15 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,46 @@

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

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
Expand Down

0 comments on commit d58bde0

Please sign in to comment.