Skip to content

Commit a72bfa0

Browse files
committed
Add Firefox Drivers to capybara_driver.rb
Chrome seems to consistently get updated with new interesting options. This commit fixes the feature helper in the new admin specs to click on table cells rather than table rows (Firefox is a bit strict with this one), and we configure `Capybara::Screenshot` to know how to take screenshots with headless firefox.
1 parent 61f675e commit a72bfa0

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

admin/lib/solidus_admin/testing_support/feature_helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def stub_authorization!(user)
1919
end
2020

2121
def find_row(text)
22-
find('table tbody tr', text:)
22+
find('table tbody tr td', text:)
2323
end
2424

2525
def find_row_checkbox(text)
26-
find_row(text).find('td:first-child input[type="checkbox"]')
26+
find('table tbody tr', text:).find('td:first-child input[type="checkbox"]')
2727
end
2828

2929
def select_row(text)

admin/spec/features/products_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
expect(page).to have_content("$19.99")
1818
expect(page).to be_axe_clean
1919

20-
find('table tbody tr', text: 'Just a product').click
20+
find_row('Just a product').click
2121

2222
expect(page).to have_current_path("/admin/products/just-a-prod")
2323
expect(page).to have_content("Manage images")

core/lib/spree/testing_support/capybara_driver.rb

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,7 @@
22

33
require "selenium/webdriver"
44

5-
Capybara.register_driver :selenium_chrome_headless do |app|
6-
browser_options = ::Selenium::WebDriver::Chrome::Options.new
7-
browser_options.args << '--headless'
8-
browser_options.args << '--disable-gpu'
9-
browser_options.args << '--no-sandbox'
10-
browser_options.args << '--window-size=1920,1080'
11-
browser_options.args << '--disable-backgrounding-occluded-windows'
12-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
5+
Capybara::Screenshot.register_driver(:selenium_headless) do |driver, path|
6+
driver.browser.save_screenshot(path)
137
end
14-
15-
Capybara.register_driver :selenium_chrome_headless_docker_friendly do |app|
16-
browser_options = ::Selenium::WebDriver::Chrome::Options.new
17-
browser_options.args << '--headless'
18-
browser_options.args << '--disable-gpu'
19-
# Sandbox cannot be used inside unprivileged Docker container
20-
browser_options.args << '--no-sandbox'
21-
browser_options.args << '--window-size=1240,1400'
22-
browser_options.args << '--disable-backgrounding-occluded-windows'
23-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
24-
end
25-
26-
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
8+
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_headless).to_sym

0 commit comments

Comments
 (0)