获取匹配XPath Count关键字不会返回所有匹配的XPATH



我正在尝试将所有RadioButtons的列表存储在我正在处理的页面中。单选按钮金额将根据我在哪个分页号而变化。

现在,我正在使用下面的代码查找所有匹配的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>

edit2:

ive将Get Matching Xpath Count更新为//div[4]/table/tbody/tr更具体,但仍然只计数11,而不是20

edit3:

如果我在第二页上执行相同的测试,则它的工作正常(返回20,然后通过20行循环(,但是第1页和第2页之间没有区别...

事实证明,RF并不真正了解页面中发生的事情。因此,我所做的是到达页面(通过NAV栏(以刷新当前页面。然后,它看到了所有20个条目,并按照预期的方式继续通过for循环。

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

如果其他人遇到了类似的问题 - 下面评论并尝试为您提供帮助:(

最新更新