I've done a few searches and I'm unable to find a suitable answer. Basically I have an unordered list which can be of a varying length. I want to iterate through the list, do some other things and then come back and select the next item on the list. I can do this fine when I define the amount of times my loop should iterate as I know the amount of items in the list.
However I don't want to define this for each test, I want to grab the number of items in the list and then pop that into a variable that I can use to exit the loop and do the next thing I want.
The HTML is like so:
<ul id="PageContent_cat">
<li class="sel">
<a target="_self" href="/searchlocation.aspx?c=S1">S1</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S2">S2</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S3">S3</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S4">S4</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S5">S5</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S6">S6</a>
</li>
<li>
<a target="_self" href="/searchlocation.aspx?c=S7">S7</a>
</li>
</ul>
So I can see there are 7 items in the list. Apparently in watir I could have used something the following:
arr= ie.select_list(:name,'lr').getAllContents.to_a
But not with webdriver.
I thought I could maybe use 'lis' but I just get a Hex result:
$bob = browser.ul(:id => "PageContent_cat").lis puts $bob
Thanks,
Paul