1
2

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.

selectbox テスト Capybara::ElementNotFound

Posted at

#前提
rspec
Capybara
導入済み

#本題
今までほとんどfill_inを使用していたためselectboxのテストを行ってみたところ下記のようなエラーにハマりました。
Capybara::ElementNotFound: Unable to find field "北海道" that is not disabled

・間違い

system.article_spec.rb
select "北海道", from 1

・変更点

system.article_spec.rb
select "北海道", from "article[place_id]"
_form.htm
<select class="form-control" id="article_place" name="article[place_id]"><option value="">選択してください</option>
<option value="1">北海道</option>
<option value="2">青森県</option>
<option value="3">岩手県</option>
<option value="4">宮城県</option>
<option value="5">秋田県</option>
<option value="6">山形県</option>
<option value="7">福島県</option>
<option value="8">茨城県</option>
<option value="9">栃木県</option>
<option value="10">群馬県</option>
<option value="11">埼玉県</option>
             ・
             ・
             ・

上記で問題なくテスト成功できました。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?