ruby on rails - Caypbararspec throwing both `Capybara::ModalNotFound` and `Selenium::WebDriver::Error::UnexpectedAlertOpenError`

So i have a "Delete" link that brings up a html confirm modal. In my rspec system test though

So i have a "Delete" link that brings up a html confirm modal. In my rspec system test though, it keeps erroring out with both errror messages Capybara::ModalNotFound and Selenium::WebDriver::Error::UnexpectedAlertOpenError.

Here are 2 different attempts I've tried so far. First was a pretty standard but got those 2 errors.

expect(page).to have_selector(:link_or_button, "Delete")
click_on "Delete"
page.driver.browser.switch_to.alert.accept
expect(page).to have_text("Team was successfully destroyed.")

Second, I thought it might be a timing/speed issue so i tried this approach next. The message result is correct, but still getting the same errors.

expect(page).to have_selector(:link_or_button, "Delete")
messege = accept_confirm do
  click_link "Delete"
end
wait_for { messege }.to eq("Are you sure you want to DELETE #{team.name}")

Rails: 8

capybara: 3.40

selenium-webdriver: 4.29

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743751125a4500917.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信