Reputation: 1218
I am trying to write a test in which I need to find an a
element, that contains a specific icon
<a href="#"><span class="icon icon-checkmark></span></a>
I tried using xpath but I am doing something wrong I guess..
save_button = find(:xpath, '//a[span(., "icon-checkmark")]')
What would be the proper way to find my save button?
Upvotes: 1
Views: 2040
Reputation: 49870
You're close, except you need to specify that you're looking for a class name.
find(:xpath, ".//a[.//span[contains(concat(' ',@class,' '), ' icon-checkmark ')]]")
The concat and extra spaces are to make sure it matches the specific class name and not a substring of a different class name.
Upvotes: 4