Given this HTML fragment
<ul>
<li>Product 1<span><a href="#">Remove</a></span></li>
<li>Product 2<span><a href="#">Remove</a></span></li>
</ul>
What’s a clean way to get the list of products as an array?:
['Product 1', 'Product 2']
I want the text of the li elements but not of the span tags.
Update:
This works:
all('ul li').map{|e| e.native.children.first.text}
but can it be improved? I’m not keen on using ‘native’ as it may be not work with all Capybara drivers.
This should do it: