-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix headless chrome setup, though may need to change path to chrome b…
…inary for github actions :-(
- Loading branch information
1 parent
bb6498e
commit e45a5eb
Showing
5 changed files
with
38 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,44 +28,35 @@ | |
# steps to use the XPath syntax. | ||
Capybara.default_selector = :css | ||
Capybara.server = :webrick | ||
<<<<<<< HEAD | ||
Capybara.register_driver :selenium do |app| | ||
# Webdrivers::Chromedriver.required_version = '123.0.6312.58' | ||
# Webdrivers::Chromedriver.required_version = '126.0.6478.126' | ||
webdriver_args = %w[--headless --no-sandbox --disable-gpu --window-size=1024,1024] | ||
options = Selenium::WebDriver::Chrome::Options.new( | ||
args: webdriver_args | ||
) | ||
# When an "unexpected" alert/confirm is displayed, accept it (ie user clicks OK). | ||
# Expected ones can be handled with accept_alert do...end or accept_confirm do...end | ||
options.unhandled_prompt_behavior = :accept | ||
======= | ||
# must have compatible versions of chromedriver and chrome-for-testing (headless) installed: | ||
# Download a specific Chrome for Testing version: | ||
# npx @puppeteer/browsers install [email protected] | ||
# Download a specific ChromeDriver version: | ||
# npx @puppeteer/browsers install [email protected] | ||
# (Note: these 'installs' just put stuff in the $cwd. brew install may be better) | ||
|
||
path_to_chromedriver = `find ~+/tmp -type f -name 'chromedriver'`.chomp | ||
#path_to_chrome_for_testing = `find ~+/tmp -type f -name 'chrome'`.chomp | ||
path_to_chrome_for_testing = `find ~+/tmp -type f -name 'Google Chrome for Testing'`.chomp | ||
|
||
Capybara.register_driver :selenium_chrome_headless do |app| | ||
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| | ||
opts.add_argument '--headless' | ||
opts.add_argument '--no-sandbox' | ||
opts.add_argument '--disable-gpu' | ||
opts.add_argument '--window-size=1024,1024' | ||
# opts.binary = File.join(Rails.root, 'tmp', 'Google Chrome for Testing.app') | ||
# When an "unexpected" alert/confirm is displayed, accept it (ie user clicks OK). | ||
# Expected ones can be handled with accept_alert do...end or accept_confirm do...end | ||
opts.unhandled_prompt_behavior = :accept | ||
opts.binary = path_to_chrome_for_testing | ||
end | ||
|
||
#service = Selenium::WebDriver::Service.chrome(path: File.join(Rails.root, 'tmp', 'chromedriver')) | ||
|
||
|
||
>>>>>>> rails5 | ||
# expects headless Chrome-for-testing and its driver to be in $RAILS_ROOT/tmp somewhere, | ||
# but puppeteer installs them in arch-specific subdirs :-( | ||
Capybara::Selenium::Driver.new( | ||
app, | ||
browser: :chrome, | ||
service: Selenium::WebDriver::Service.chrome(path: path_to_chromedriver), | ||
options: options, | ||
clear_session_storage: true, | ||
clear_local_storage: true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters