Can't click buttons of modal download dialog with Poltergeist

When I click the button, the bootstrap popup is displayed. I tried to click OK or Cancel using Poltergeist functions as shown below, but none worked. Either the functions don't work or they click outside.

<div class="modal-footer">
<a class="btn cancel" data-dismiss="modal" href="#">Cancel</a>
<a class="btn proceed btn-primary" href="#">OK</a>
</div>

click_link "Release"
page.driver.render('ReleaseOKCANCEL.jpg', :full =>true)

      

When you click on the "release" button, there will be a boot modal with "OK" and "Cancel" buttons, which can be checked using screenshots. Trying to click OK using the commands below.

  • page.find ('btn.proceed.btn-primary'). Trigger ('click')
  • click_link ('OK')
  • page.execute_script ('$ ("btn.proceed.btn primary"). Trigger ("click"))
  • page.execute_script ('$ ("btn.proceed.btn primary"). Trigger ("hang"). Trigger ("cli cc")')
  • page.all (".//* [@ID = 'confirmation_dialog'] / cases [3] / a [2]"). First.click
  • click_button "OK"
  • click_on "OK"
  • page.dismiss_confirm do page.find ('. btn.proceed.btn-primary'). click end
  • page.find ('modal'). Find ('. Modal-footer'). Find ('. Btn.proceed.btn primary'). Trigg er ('click')

But nothing works. After clicking OK, the status will change in the application. But that doesn't happen.

+3


source to share


1 answer


I've been writing a few feature / integration specs over the past few weeks - and have targeted a lot of fields and buttons in bootstrap models (although the class names have been changed from the bootstrap defaults).

Here's a test that works great for me with vanilla bootstrap:

 it "displays edit profile page pre-filled for editing after successful form submission" do
    click_link "List a Property"

    within("form#new_user") do
      fill_in "user[login]", with: user.username
      fill_in "user[password]", with: user.password
      fill_in "user[email]", with: user.email
      fill_in "user[first_name]", with: user.first_name
      fill_in "user[last_name]", with: user.last_name
      fill_in "user[phone_number]", with: user.phone_number
      click_button "List My Properties"
    end

    expect(current_path).to eq account_path(:profile)
    within(".profile-name") { expect(page).to have_content user.username }
    find_field("user[first_name]").value.should eq user.first_name
  end

      



Using the in () method inside Capybara usually saves a lot of targeting problems that I would otherwise run into.

I should also note that all js tests are included with the following line:

describe "User", js: :true do

      

0


source







All Articles