Capybara find_field to find a disabled field

By default find_field in capybara only finds an enabled field. To find a disabled field, you can pass in a second argument as an options hash.

For example, to find a field that is disabled, having a label of “Promo Code”, you can do the following

find_field('Promo Code', {disabled: true})

As per the docs, you can pass in the following values for disabled

  • true – only finds a disabled field
  • false – only finds an enabled field
  • :all – finds either an enabled or disabled field
Ryan Sukale

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published.