如何等到 Capybara 中的元素消失?
How to wait until an element disappears in Capybara?
注意:当我写完这个问题时,解决方案就出现了,但也许其他人会觉得这很有用,或者可以提供替代方案。
我已阅读以下文章:
本帖:
https://groups.google.com/forum/#!topic/ruby-capybara/Mz7txv1Sm0U
此博客:https://nulogy.com/articles/sleep-is-for-the-weak#.VNVcIrDF8vs
和这个 Whosebug 问题:Capybara synchronize with has_no_css?
但仍然无法拼凑出这个特定问题的答案。
我想等到页面上的某个元素消失后再继续。
此元素与我要单击的另一个元素重叠。无论如何,当我尝试单击目标元素时,出现此错误:
Capybara::Poltergeist::MouseEventFailed:
Firing a click at co-ordinates [1006, 322] failed. Poltergeist detected another element with CSS selector 'html body.widgets div#select2-drop-mask.select2-drop-mask' at this position. It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
连.trigger('click')
和.trigger(:click)
我都试过了,好像没什么效果。
我尝试过的其他一些东西('thing'是消失的元素):
@page.wait_until_thing_invisible
SitePrism::TimeOutWaitingForElementInvisibility:
execution expired
经过更多调查,该元素似乎没有消失,因为另一个问题。
Failure/Error: expect(@page.thing.results.map(&:text)).to include a_string_matching 'search_query'
expected ["Searching…"] to include (a string matching "search_query")
Diff:
@@ -1,2 +1,2 @@
-[(a string matching "search_query")]
+["Searching…"]
"Searching..." 显示仅一瞬间,需要稍等片刻才能尝试点击结果。
所以现在我想等到看不到 "Searching...",然后继续下一次点击。
我最后做了这个 while 语句:
while search_complete = @page.thing.results.map(&:text).reduce.include?('Searching')
sleep 1
end
而这似乎要等到"Searching..."消失,真正的结果出现。
注意:当我写完这个问题时,解决方案就出现了,但也许其他人会觉得这很有用,或者可以提供替代方案。
我已阅读以下文章:
本帖: https://groups.google.com/forum/#!topic/ruby-capybara/Mz7txv1Sm0U
此博客:https://nulogy.com/articles/sleep-is-for-the-weak#.VNVcIrDF8vs
和这个 Whosebug 问题:Capybara synchronize with has_no_css?
但仍然无法拼凑出这个特定问题的答案。
我想等到页面上的某个元素消失后再继续。
此元素与我要单击的另一个元素重叠。无论如何,当我尝试单击目标元素时,出现此错误:
Capybara::Poltergeist::MouseEventFailed:
Firing a click at co-ordinates [1006, 322] failed. Poltergeist detected another element with CSS selector 'html body.widgets div#select2-drop-mask.select2-drop-mask' at this position. It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
连.trigger('click')
和.trigger(:click)
我都试过了,好像没什么效果。
我尝试过的其他一些东西('thing'是消失的元素):
@page.wait_until_thing_invisible
SitePrism::TimeOutWaitingForElementInvisibility:
execution expired
经过更多调查,该元素似乎没有消失,因为另一个问题。
Failure/Error: expect(@page.thing.results.map(&:text)).to include a_string_matching 'search_query'
expected ["Searching…"] to include (a string matching "search_query")
Diff:
@@ -1,2 +1,2 @@
-[(a string matching "search_query")]
+["Searching…"]
"Searching..." 显示仅一瞬间,需要稍等片刻才能尝试点击结果。
所以现在我想等到看不到 "Searching...",然后继续下一次点击。
我最后做了这个 while 语句:
while search_complete = @page.thing.results.map(&:text).reduce.include?('Searching')
sleep 1
end
而这似乎要等到"Searching..."消失,真正的结果出现。