【发布时间】:2017-05-17 13:35:37
【问题描述】:
我在这里有一个集成测试,每次都使用 poltergeist 驱动程序完美通过,但是当我使用 Selenium 运行这个测试时,它平均通过 3 次,失败 1 次。
def fill_in_inclusion_criteria
find("div.measure#age label[for='16']").click
find("div.measure#substance_use_met label[for='1']").click
find("div.measure#participant_consent label[for='1']").click
click_link("Next")
end
当它失败时,我返回的错误是这样的
expected to find css "div.measure#participant_consent" but there were no matches. Also found "", which matched the selector but not all filters.
点击div.measure#age label[for='16']时会出现参与者同意按钮,因此它依赖于Javascript。我大部分时间都在 Firefox 中看到这种情况,但是当它出错时,该 div 在页面上不可见。
似乎在点击之前它没有等待元素显示在页面上,但我认为将它包装在“查找”中会等待元素在页面上可见,然后再尝试点击它?
知道为什么会发生这种情况吗?
【问题讨论】:
标签: ruby-on-rails selenium testing capybara