获取匹配的 Xpath 计数关键字不 return 所有匹配的 Xpath

Get Matching Xpath Count Keyword does not return all matching Xpaths

我试图在我正在处理的页面中存储所有单选按钮的列表。单选按钮数量将根据我所在的分页编号而变化。

现在我正在使用下面的代码找到所有匹配的 Xpath 并将其存储在一个变量中。

*** Keywords ***
Count How Many RadioButtons On Page
    ${Count}    Get Matching Xpath Count    //tr
    ${CountList}    Create List
    : FOR    ${INDEX}    IN RANGE    1    ${Count}
    \    Append To List    ${CountList}    xpath=//tr[${INDEX}]
    log    ${CountList}
    Set Global Variable    ${CountList}

这只存储了 11 个条目。当页面实际包含 20 个时。由于某种原因,它缺少其他 9 个,我不知道为什么。

最后,CountList 变量如下所示:

u'xpath=//tr[1]', u'xpath=//tr[2]', u'xpath=//tr[3]', u'xpath=//tr[4]', u'xpath=//tr[5]', u'xpath=//tr[6]', u'xpath=//tr[7]', u'xpath=//tr[8]', u'xpath=//tr[9]', u'xpath=//tr[10]', u'xpath=//tr[11]'

这个列表应该一直到 //tr[20]

我还可以确认使用(例如)//tr[12] 或更高版本将正常工作。只是 Get Matching Xpath Count 出于某种原因没有拉出所有 20 个。

谁能照亮这个?

编辑:

以下是我要计算的页面 HTML 的一部分:

<tbody id="oKGQf0-rows">
    <tr id="oKGQ_1" class="z-listitem z-listitem-selected">
        <td id="oKGQ0q" class="z-listcell">
            <div id="oKGQ0q-cave" class="z-listcell-content"><span id="oKGQ_1-cm" class="z-listitem-checkable z-listitem-radio"><i class="z-listitem-icon z-icon-radio"></i></span>&nbsp;P-DAC-15-790</div>
        </td>
        <td id="oKGQ1q" class="z-listcell">
            <div id="oKGQ1q-cave" class="z-listcell-content">DATA</div>
        </td>
        <td id="oKGQ2q" class="z-listcell">
            <div id="oKGQ2q-cave" class="z-listcell-content">..DATA</div>
        </td>
        <td id="oKGQ3q" class="z-listcell" title="AMD Contractors Work Permit">
            <div id="oKGQ3q-cave" class="z-listcell-content">15</div>
        </td>
        <td id="oKGQ4q" class="z-listcell">
            <div id="oKGQ4q-cave" class="z-listcell-content">i9</div>
        </td>
        <td id="oKGQ5q" class="z-listcell">
            <div id="oKGQ5q-cave" class="z-listcell-content">DATA</div>
        </td>
        <td id="oKGQ6q" class="z-listcell">
            <div id="oKGQ6q-cave" class="z-listcell-content">&nbsp;</div>
        </td>
        <td id="oKGQ7q" class="z-listcell">
            <div id="oKGQ7q-cave" class="z-listcell-content">26-06-2015 14:50</div>
        </td>
        <td id="oKGQ8q" class="z-listcell">
            <div id="oKGQ8q-cave" class="z-listcell-content">&nbsp;</div>
        </td>
        <td id="oKGQ9q" class="z-listcell">
            <div id="oKGQ9q-cave" class="z-listcell-content">&nbsp;</div>
        </td>
    </tr>
    <tr id="oKGQ11" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQ31" class="z-listitem">
    </tr>
    <tr id="oKGQ51" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQ91" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQb1" class="z-listitem">
    </tr>
    <tr id="oKGQd1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQf1" class="z-listitem">
    </tr>
    <tr id="oKGQh1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQj1" class="z-listitem">
    </tr>
    <tr id="oKGQl1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQn1" class="z-listitem">
    </tr>
    <tr id="oKGQp1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQr1" class="z-listitem">
    </tr>
    <tr id="oKGQt1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQv1" class="z-listitem">
    </tr>
    <tr id="oKGQx1" class="z-listitem z-listbox-odd">
    </tr>
    <tr id="oKGQz1" class="z-listitem">
    </tr>
    <tr id="oKGQ02" class="z-listitem z-listbox-odd">
    </tr>
</tbody>

编辑 2:

我已将 Get Matching Xpath Count 更新为 //div[4]/table/tbody/tr 更具体一些,但它仍然只计算 11,而不是 20

编辑 3:

如果我在第 2 页执行相同的测试,它完全可以正常工作(returns 20,并循环遍历 20 行)但是第 1 页和第 2 页之间没有区别...

事实证明,RF 并没有真正理解页面中发生了什么。所以我所做的是当我到达页面(通过导航栏)然后刷新当前页面。然后它看到所有 20 个条目并按预期继续执行 for 循环。

我不知道这是否是 Selenium2Library 的 RF 中的错误,但在尝试完成逻辑任务时,我基本上不需要重新初始化网页。

如果其他人遇到类似的问题 - 请在下方评论,我会尽力帮助您 :)