0

注意:当我写完这个问题时,解决方案本身就出现了,但也许其他人可能会觉得这很有用,或者可以提供替代方案。

我已阅读以下文章:

但仍然无法拼凑出这个特定问题的答案。

我想等到页面上的元素消失后再继续。

此元素与我要单击的另一个元素重叠。当我尝试单击目标元素时,我收到此错误:

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')and .trigger(:click)even,但似乎没有效果。

我尝试过的其他一些事情(“东西”是消失的元素):

@page.wait_until_thing_invisible
 SitePrism::TimeOutWaitingForElementInvisibility:
   execution expired
4

1 回答 1

1

经过更多调查,由于另一个问题,该元素似乎没有消失是正确的。

     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…"]

“正在搜索...”显示会出现一瞬间,在尝试单击结果之前需要等待。

所以现在我想等到我没有看到“正在搜索...”,然后继续下一次点击。

我最终做出了这个 while 声明:

while search_complete = @page.thing.results.map(&:text).reduce.include?('Searching')
  sleep 1
end

而这似乎要等到“正在搜索...”消失并出现真正的结果。

于 2015-02-07T01:19:34.283 回答