I am trying to automate a block appearing on the website and comparing its content through CMS table.
The issue is I have managed to automate the block appearing on the UI but when I login as admin and try to save the content of the table in an array using iteration there where I fail to do it.
<table id="nodequeue-dragdrop" class="nodequeue-dragdrop sticky-enabled tabledrag-processed sticky-table">
<thead class="tableHeader-processed">
<tbody>
<tr class="draggable odd">
<td>
<a class="tabledrag-handle" href="#" title="Drag to re-order">
<a href="/car-news/moscow/new-text-1">New Text 1</a>
</td>
<td>
<td>2012-06-06 10:24</td>
<td style="display: none;">
<td>
<td>
<td class="position">1</td>
</tr>
<tr class="draggable even">
<td>
<a class="tabledrag-handle" href="#" title="Drag to re-order">
<a href="/car-news/new-cars/text-2">Text 2 </a>
</td>
<td>
<td>2012-06-06 10:29</td>
<td style="display: none;">
<td>
<td>
<td class="position">2</td>
</tr>
<tr class="draggable odd">
<td>
<a class="tabledrag-handle" href="#" title="Drag to re-order">
<a href="/car-news/new-cars/this-is-text-3">This is Text 3</a>
</td>
<td>
<td>2012-06-05 12:55</td>
<td style="display: none;">
<td>
<td>
<td class="position">3</td>
</tr>
The code that I am using is
@text = Array.new
x = 1
y = 0
until x == 10
y = x -1
until y == x
@text[y] = @browser.table(:id,'nodequeue-dragdrop').tbody.row{x}.cell{1}.link(:href =>/car-news/).text
puts @text[y]
y=y+1
end
x=x+1
end
The problem is the scripts runs successfully but even though i have set an iteration the script only reads the 1st element and displays it text and does not goto the 2nd 3rd…and so on elements.
Justin is headed the right direction with using ruby’s built in methods for iterating over collections. But consider this, If I am reading your code right, you know you are after the text from specific links, so why iterate over the rows when you could just make a collection of matching links?