0
0

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 5 years have passed since last update.

【RSpec】CSSのクラスではなくtypeからinput要素を操作する方法

Last updated at Posted at 2020-02-26

概要

  • RSpecでclick_on '文字列'の文字列を今後変更しても対応できるようにRSpecを書く場合に調べたことのメモ
  • findでCSSのクラス名を使わずにtypeから要素を選択する方法

該当のHTML

<div class="auth-form__submit">
  <input type="submit" name="commit" value="確認" data-disable-with="送信中...">
</div>

RSpecのコード

Before

click_on '送信'

After

find('input[type="submit"]').click

まとめ

これでHTML側で文言が変更されても対応できるようにRSpecを改修することができました。

参考記事

RSpec Capybara name / id のない input の fill_in にハマる

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?