我正在尝试自动化出现在网站上的块并通过 CMS 表比较其内容。问题是我已经设法自动化出现在 UI 上的块,但是当我以管理员身份登录并尝试使用迭代将表的内容保存在数组中时,我没有做到这一点。
<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>
我正在使用的代码是
@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
问题是脚本运行成功,但即使我设置了迭代,脚本也只读取第一个元素并显示它的文本,并没有转到第二个第三个......等等元素。