0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Capybaraで特定の要素の出現を待つwait処理を考えた

Last updated at Posted at 2018-09-21

Sleepで調整しても不安定なので、
loopとrescueで実装しました。

waitting_element.rb

def wait_display_element element
  loop{
    sleep 5
    p 'waitting....'
    begin
      @session.first(:css, element).text
      break
    rescue
    end
  }
end

wait_display_element 'h3.apperelement'

みたいな感じでmethodをcallしてあげれば、
勝手にRetryして、elementが出現するのを待ってくれる。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?