Skip to content

Commit 708dee4

Browse files
committed
Increase window-size for headless features tests
:selenium_chrome_headless driver has a default window-size of (800x600). This small window-size seems to result in the `Selenium::WebDriver::Error::ElementClickInterceptedError:` This commit increases the window-size and also reverts the prior fix for these errors (commit 55321d0)
1 parent 55321d0 commit 708dee4

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

spec/features/super_admins/merge_org_spec.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,7 @@
4545
expect(page).to have_text('Merge Organisations')
4646
choose_suggestion('org_org_name', @to_org)
4747

48-
# rubocop:disable Layout/LineLength
49-
# Using JS to click on button as click_button 'Analyze' fails due to error like
50-
# Selenium::WebDriver::Error::ElementClickInterceptedError: element click intercepted:
51-
# Element <button name="button" type="submit" class="btn btn-primary">...</button> is not clickable at point (86, 349).
52-
# Other element would receive the click: <div id="ui-id-2" tabindex="-1" class="ui-menu-item-wrapper">...</div>
53-
# So replacing click_button 'Analyze'with
54-
# rubocop:enable Layout/LineLength
55-
analyze_button = find('button', text: 'Analyze')
56-
execute_script('arguments[0].click();', analyze_button)
57-
48+
click_button 'Analyze'
5849
# Wait for response
5950
sleep(0.3)
6051
expect(page).to have_text('Summary:')

spec/features/templates/templates_upgrade_customisations_spec.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,7 @@
5252

5353
# Move to the other funder Org's Templates
5454
choose_suggestion('superadmin_user_org_name', funder)
55-
56-
# rubocop:disable Layout/LineLength
57-
# Using JS to click as click_button "Change affiliation" fails due to error like
58-
# Selenium::WebDriver::Error::ElementClickInterceptedError: element click intercepted:
59-
# Element <input type="submit" name="commit" value="Change affiliation" class="btn btn-secondary" data-disable-with="Change affiliation">
60-
# is not clickable at point (101, 203). Other element would receive the click: <div id="ui-id-2" tabindex="-1" class="ui-menu-item-wrapper">...</div>
61-
# So replacing click_button('Change affiliation')
62-
# rubocop:enable Layout/LineLength
63-
change_affiliation_input_button = find('input[value="Change affiliation"]')
64-
execute_script('arguments[0].click();', change_affiliation_input_button)
55+
click_button('Change affiliation')
6556

6657
# Edit the original Template
6758
click_link "#{funder.name} Templates"

spec/support/capybara.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
# Use the fast rack_test driver for non-feature tests by default
77
Capybara.default_driver = :rack_test
88

9+
# Create a custom driver based on Capybara's :selenium_chrome_headless driver
10+
# This resolves a ElementClickInterceptedError when executing `click_button 'Sign in'` with DMP Assistant
11+
Capybara.register_driver :selenium_chrome_headless_add_window_size do |app|
12+
# Get a copy of the default options for Capybara's :selenium_chrome_headless driver
13+
options = Capybara.drivers[:selenium_chrome_headless].call.options[:options].dup
14+
options.add_argument('--window-size=1920,1080') # default window-size is only (800x600)
15+
# Create a new Selenium driver with the customised options
16+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
17+
end
18+
919
RSpec.configure do |config|
1020
config.before(:each, type: :feature, js: false) do
1121
Capybara.use_default_driver
1222
end
1323

1424
# Use the Selenium headless Chrome driver for feature tests
1525
config.before(:each, type: :feature, js: true) do
16-
Capybara.current_driver = :selenium_chrome_headless
26+
Capybara.current_driver = :selenium_chrome_headless_add_window_size
1727
end
1828
end

0 commit comments

Comments
 (0)