elstgav
elstgav

Reputation: 1061

Check Element Properties with Capybara

How do I check the DOM properties of an element I've selected with Capybara? (note that this is different from checking attributes)

Example: I want to see if a checkbox is in the indeterminate state, and I'd like to do something like this:

find('input[type="checkbox"]').properties.indeterminate == true

Upvotes: 1

Views: 182

Answers (1)

elstgav
elstgav

Reputation: 1061

Looks like the best method I have is JavaScript:

  def has_indeterminate_field?(text)
    page.evaluate_script "$('label:contains(#{text}) input')[0].indeterminate"
  end

Upvotes: 1

Related Questions