I changed from selenium webdrive to capybara-webkit, and the issue no longer occurred.
Capybara + Selenium: save_and_open_page shows button, but capybara can't find it
-
28-06-2023 - |
Domanda
My capybara test includes these lines:
click_button "SHARE"
fill_in 'Email Address', :with => @user_two.email
save_and_open_page
click_button 'CONFIRM'
the share button would make a modal visible. Filling in the email address text box of this modal seems to go off without a hitch, but I receive the following error for the button
Capybara::ElementNotFound:
Unable to find button "CONFIRM"
However, when I save_and_open_page, the button is visible.
I've tried switching to
page.find("#id-of-button").click
but Capybara can't find that either.
It's interesting to note the save_and_open_page shows me a page where the field for email hasn't been filled in.
I think I might be missing something basic about how save_and_open_page works because if that is the page Capybara is seeing in its totality then these errors make no sense to me...
edit: Modal view code
.title.aaux
Title
.content
.line-separator
#intro
Enter Email:
= form_for(patient, url: {controller: "dashboard/patients", action: "share_with_user"}, method: :post, html: {id: "share-patient-form"}) do |f|
%fieldset.bordered
= f.text_field :share_user_email, placeholder: "Email Address", class: "aaux form-control"
.line-separator
#button-row
%button.btn.btn-success.aaux.pull-right#confirm-share-patient{type: "submit"}
CONFIRM
%button.btn.btn-cancel.aaux.pull-right#close-modal-share-patient
CANCEL
edit: source code generated for button
<button type="submit" id="confirm-share-patient-button" class="btn btn-success aaux pull-right">
CONFIRM
</button>
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow