Read more

Reading an element's attributes with Capybara

Thomas Klemm
January 07, 2015Software engineer

capybara_element['attribute_name'] Show archive.org snapshot allows accessing an element's attributes in Capybara.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

A few examples:

find('#my_element')['class']
# => "first-class second-class"

find('#my_input')['placeholder']
# => "My placeholder value"

find('a#example-link')['href']
# => "http://example.com"

find('#my_element')['missing_attribute']
# => nil
Posted by Thomas Klemm to makandra dev (2015-01-07 11:43)