I am trying to return an array of elements of HTML that have the same class. I actually saw some similar questions such as
How to get the number of elements having same attribute in HTML in Watir?
Watir: How to retrieve all HTML elements that match an attribute? (class, id, title, etc)
HTML looks like this
<table class="module grid grid-50">
<span bo-bind="row.date | sgDate">20/04/2018</span>
<span bo-bind="row.date | sgDate">22/04/2018</span>
<span bo-bind="row.date | sgDate">23/06/2018</span>
<span bo-bind="row.date | sgDate">06/09/2018</span>
<span bo-bind="row.date | sgDate">15/09/2018</span>
</table
I have tried
content = browser.elements(:class => "module.grid.grid-50") puts content
which return <Watir::HTMLElementCollection:0x00000000053fc460>
Instead of this message, I would like to output an array of these dates. I think I am missing something here but do not know what exactly.
I read on Rubydoc that ElementCollection includes to_a
method that returns collection as array and was wondering if it would be possible to include it here as well.