Capybara - how to test presence of class attribute for nth element
I have a list like this
<ul>
<li></li>
<li .current></li>
<li></li>
</ul>
and if a user clicks on an li it adopts the class "current". I want to test this in capybara but im wondering how to write the test. I want to be specific in the test by saying the second element should only have the class "current".
i know how to target the second element using xpath i.e //li[2] a开发者_StackOverflow中文版nd i also know how target an element by class //li[@class="current"] but i dont know how to bring them both together to to write this test.
Is this what you want? :)
assert _the_li_element_you_found.node[:class] == "current"
精彩评论