Javascript confirmation dialog in capybara webkit driver

So, I want to check how a user deletes his account using capybara and rspec:

scenario "User wants to delete their account" do
  click_link "Account"
  click_link "Delete My Account"
  expect(page).to have_text("You're account was deleted.")
end

Only problem is the js confirmation dialog when the user clicks โ€œdelete my accountโ€. To confirm this dialog box, I did the following:

  • Install capybara-webkit
  • add Capybara.javascript_driver = :webkitto my spec_helper.rb
  • add :js => truein scenario "User wants to delete their account" do.

Now nothing works with the add :js => true. Am I getting an error Capybara::ElementNotFound: Unable to find link "Account"and, before it works fine, js: trueinterferes with these capybara methods? Is my configuration wrong?

+3
source share
3

, , . , javascript, .

page.execute_script('$(".dropdown-toggle").dropdown("toggle");')
-1

:js => true Capybara JavaScript ; , JavaScript . JS.

... :

  • " " , " ". ?
  • , (.. ). , Poltergeist
0

Check your visit path before clicking "Delete my account."

scenario "User wants to delete their account" do
  click_link "Account"
  expect (current_path) .to eq '/ my_accout'
  click_link "Delete My Account"
  expect (page) .to have_text ("You're account was deleted.")
end

0
source

All Articles