加载页面后,我有运行和隐藏的代码,并根据xhr返回的数据显示各种项目.
我的集成测试看起来像这样:
it "should not show the blah" do
page.find('#blah').visible?.should be_true
end
Run Code Online (Sandbox Code Playgroud)
当我在上下文中手动转到该测试运行的页面时,#blah 并不像我预期的那样可见.我怀疑Capybara正在查看页面的初始状态(在这种情况下是不可见的),在JS运行之前评估DOM的状态并且未通过测试.
是的,我设置:js => true了包含的描述块:)
任何想法将不胜感激!我希望我不必在这里故意拖延,感觉不稳定,会减慢速度.
我有一个测试,在页面上呈现两个相同的元素.我理解错误的问题是什么,但我不确定如何修复它?这是我的测试:
it "deletes the correct snitch" do
user = login_user
snitch = create(:snitch, :healthy, owner: user.accounts.first)
snitch2 = create(:snitch, :healthy, owner: user.accounts.first)
visit root_path
delete = page.find(".icon-delete")
first(delete).click
expect(page).to have_content("Please confirm this delete.")
end
Run Code Online (Sandbox Code Playgroud)
Managing snitches deleting a snitch from the index page deletes the correct snitch
Failure/Error: delete = page.find(".icon-delete")
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching css ".icon-delete"
Run Code Online (Sandbox Code Playgroud)
如何选择页面上的其中一个图标删除?