Skip to content

Commit d5694a1

Browse files
mamhofftvdeyen
authored andcommitted
Use Firefox for system specs
Chrome seems to consistently get updated with new interesting options, and our specs have been sometimes more, and sometimes less flaky with Chrome as the browser that drives our system specs. This change uses the preconfigured `selenium_headless` driver from the Selenium gem, which uses Firefox under the hood. There are a few changes to helpers in the new admin. All of them have to with clicking table cells rather than the underlying table row. This is how real users also interact with the respective page, so I think it's a good change.
1 parent a85ae3c commit d5694a1

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-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")
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# frozen_string_literal: true
22

33
require "selenium/webdriver"
4+
require "capybara-screenshot"
45

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)
6+
Capybara::Screenshot.register_driver(:selenium_headless) do |driver, path|
7+
driver.browser.save_screenshot(path)
138
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
9+
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_headless).to_sym

0 commit comments

Comments
 (0)