capybara
capybara copied to clipboard
Capybara with Selenium-webdriver: button found but not clicked
Meta
Capybara Version: 3.40.0 Driver Information (and browser if relevant): selenium-webdriver 4.10.0 and Chrome
Expected Behavior
"Continue" button is clicked sending a POST request to my Controller and advancing the setup flow.
Actual Behavior
"Continue" button is located, click is performed but no action is taken.
Steps to reproduce
require 'rails_helper'
RSpec.feature 'Validation Configuration', type: :feature do
let!(:system_admin) { admin_user }
# Working scenario
scenario "create new DEA validation" do
login system_admin
visit new_system_admin_validation_configuration_path
expect(page).to have_css('h1', text: 'Create New User Validation Configuration')
check('validation_configuration_run_on_auto_approval', visible: false)
# Select Physician from select2 optgroup element
find(:xpath, "//optgroup[@label='All Healthcare Professional']//option[text()='Physician (MD, DO)']").select_option
choose('validation_configuration[validation_type]', option: 'dea', visible: false)
click_on 'Continue'
expect(page).to have_text('Review the information below and make sure it is correct.')
click_on 'Submit'
expect(page).to have_text('A new user validation configuration has been successfully completed.')
click_on 'Back to User Validation Configurations Page'
expect(page).to have_css('h1', text: 'User Validation Configurations')
end
# Scenario in which "Continue" button is not working
scenario "create new WEB SERVICE validation" do
login system_admin
visit system_admin_web_service_configurations_path
expect(page).to have_css('h1', text: 'Web Service Configurations')
click_on 'Add New Web Service'
fill_in 'Name', with: 'Web Service Name'
fill_in 'Base URL', with: 'example.com'
select 'Rest API', from: 'API Type'
fill_in 'Access Token URL', with: 'example.com'
fill_in 'Client Key', with: 'anykey'
fill_in 'Client Secret', with: 'anysecret'
fill_in 'Scope', with: 'anyscope'
click_on 'Continue'
find(:xpath, '//*[@id="content"]/div[3]/div/div/div[3]/div/button[1]').click
expect(page).to have_css('h1', text: 'User Validation Configurations')
end
end
Capybara is configured to use its default options for selenium-webdriver. The line that is causing the issue is:
find(:xpath, '//*[@id="content"]/div[3]/div/div/div[3]/div/button[1]').click
I've also tried:
click_on 'Submit'
The button needing to be clicked is nothing out of the ordinary:
Can anyone help me track down this issue? I'm willing to open a PR if it's necessary but I'm at a loss for what could be causing the behavior to begin with. Thank you!