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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
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)