【发布时间】:2017-04-04 17:11:35
【问题描述】:
这是一个 Rspec 功能。
given (:send_selector){ 'button.confirm'}
feature "when talent has not applied." do
given (:apply_button) { find('button[data-selector="offer-apply-button"]') }
before(:each) { visit offer_path(offer.id) }
scenario "Talent applies to offer with default cv", js: true do
apply_button.click
expect(page).to have_selector(send_selector)
find_button(send_selector).click
wait_for_ajax
# other expectations
end
end
它通过了拥有选择器的期望,但随后它抛出了错误
Capybara::ElementNotFound:
Unable to find button "button.confirm"
用find_button(send_selector).click指向那一行
我也尝试过使用page.find_button(send_selector).click
和find_button(send_selector).trigger('click') 但第一个仍然抛出错误,第二个似乎什么都不做,因为负责该操作的控制器从未被调用,并且当我在下一行截屏时模态仍然存在。
我运行了 poltergeist 调试器,页面上出现了 html。
这是水豚看到的模态(使用save_screenshot()方法)
【问题讨论】:
标签: javascript ruby-on-rails rspec capybara poltergeist