LoginSignup
0
0

More than 5 years have passed since last update.

visibilityのcapybaraテスト

Last updated at Posted at 2016-05-24

目的

普段はvisibility: hidden;になり表示されないけど何かのボタンを押した瞬間表示される
よね?というテストを書きたい。

結論

have_selectorにvisibleオプションをつけてテストすればOK

アプローチ

失敗

expect(page).to have_no_css(識別子名)では意味がない。
隠れているだけで要素そのものはブラウザに読み込まれているから。

こうした

expect(page).to have_selector(識別子名, visible: false)

$(なんかのボタン).click

expect(page).to have_selector(識別子名, visible: true)

これで動く

0
0
0

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
0