Posted almost 6 years ago. Visible to the public. Repeats.

Reading an element's attributes with Capybara

capybara_element['attribute_name'] allows accessing an element's attributes in Capybara.

A few examples:

Copy
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

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Thomas Klemm
Last edit:
almost 6 years ago
by Besprechungs-PC
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Klemm to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more