はじめに
- Frankでテストを書いているとtouchするときに以下のエラーがでた
- some views could not be touched (probably because they are not within the current viewport) (RuntimeError)
対策
- このエラーはtouchするターゲットが取得できていないときに発生する
- SeleniumではElement not found的な感じ
- 自動で取得するまで待ってはくれないので待機時間を挟む必要がある
- 以下のように対策した
- touchをオーバーライドした
- 不正なセレクタを渡したときのエラーはそのまま(エラーとして出す)
- 早すぎてとれていないという場合にのみリトライをするようにした
module Frank
module Cucumber
module FrankHelper
def touch( uiquery )
views_touched = frankly_map( uiquery, 'touch' )
raise "could not find anything matching [#{uiquery}] to touch" if views_touched.empty?
self.touch(uiquery) if views_touched.first == false # この1行を追加
end
end
end
end
~ただの宣伝~
- 全国のSeleniumer必読
- Seleniumerといっていますが、Selenium, SauceLabs, Travis, Jenkinsに関するノウハウ書いているのでよかったら参考にしてみてください