Skip to content

Commit a9adf03

Browse files
committed
Fix window resizing of solidus_chrome_headless driver
Fixes errors similar to the one below when running `solidus_chrome_headless` in a Solidus extension: ``` 1) Checkout leaving and returning to address step Got 0 failures and 2 other errors: 1.1) Failure/Error: visit spree.root_path NoMethodError: undefined method `args' for nil:NilClass # ./spec/features/checkout_spec.rb:25:in `block (2 levels) in <top (required)>' # ./spec/support/confirm_helpers.rb:14:in `block (2 levels) in <top (required)>' ``` According to #183: > After updating to cimg/ruby:2.7-browsers, we have a newer version of Selenium running on CircleCI. As such, we need to define our configuration in a way that is compatible with the new version.
1 parent 2a924be commit a9adf03

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/solidus_dev_support/rspec/capybara.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Allow to override the initial windows size
66
CAPYBARA_WINDOW_SIZE = ENV.fetch('CAPYBARA_WINDOW_SIZE', '1920x1080').split('x', 2).map(&:to_i)
7+
CAPYBARA_WINDOW_WIDTH = CAPYBARA_WINDOW_SIZE[0]
8+
CAPYBARA_WINDOW_HEIGHT = CAPYBARA_WINDOW_SIZE[1]
79

810
Capybara.javascript_driver = ENV.fetch('CAPYBARA_JAVASCRIPT_DRIVER', "solidus_chrome_headless").to_sym
911
Capybara.default_max_wait_time = 10
@@ -12,7 +14,9 @@
1214
Capybara.drivers[:selenium_chrome_headless].tap do |original_driver|
1315
Capybara.register_driver :solidus_chrome_headless do |app|
1416
original_driver.call(app).tap do |driver|
15-
driver.options[:options].args << "--window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}"
17+
driver.resize_window_to(
18+
driver.current_window_handle, CAPYBARA_WINDOW_WIDTH, CAPYBARA_WINDOW_HEIGHT
19+
)
1620
end
1721
end
1822
end

0 commit comments

Comments
 (0)