0

感谢您花时间准备我的问题。对于由图像右侧的文本表示的特定节点子节点,我需要将鼠标悬停在图像(cog.png)上然后将鼠标按下。我可以成功地定位课程,但无法确定如何单独定位图像。

HTML,我想定位“澳大利亚”附近的 cog.png

<div id="tree" class="">
<ul class="dynatree-container dynatree-no-connector">
    <li class="dynatree-lastsib">
        <span class="dynatree-node dynatree-expanded dynatree-has-children dynatree-lastsib dynatree-exp-el dynatree-ico-e"></span>
        <ul style="">
            <li class="">
                <span class="dynatree-node dynatree-exp-c dynatree-ico-c" style="background-color: transparent;">
                    <span class="dynatree-connector"></span>
                    <img alt="" src="/icn/cog.png"></img>
                    <a class="dynatree-title" title="This option is Active" href="#">
                        Australia
                    </a>
                </span>

Selenium IDE 的目标代码(针对整个跨度,我只想要图像 cog.png)

//span[contains(@class,'dynatree-node')  and //img[@src='/icn/cog.png'] and .//text()='Australia']

我试过了

//img[@src='/icn/cog.png']

毫不奇怪,它不够具体,并针对图像的第一个实例

版本

  • 火狐 32.0.3
  • 硒 IDE:2.7.0
4

1 回答 1

0

这是我用来在 dynatree 上导航的代码,它变得更加困难,因为第一项是作为子项添加的,其余的添加在子项的下方或上方。我通过创建“计数”来确定添加项目的时间点来跟踪。

<tr>
    <td>waitForTextPresent</td>
    <td>Australia</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>//span/a[contains(., '${LocationLevel1Ext}')]/preceding::span[@class='dynatree-expander'] [1]</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>//span/a[contains(., '${LocationLevel2Ext}')]/preceding::span[@class='dynatree-expander'] [1]</td>
    <td></td>
</tr>
<tr>
    <td>clickAt</td>
    <td>//span/a[contains(., '${PreviousLocationName}')]/preceding::img[@src='/icn/cog.png'] [1]</td>
    <td></td>
</tr>
<tr>
    <td>waitForTextPresent</td>
    <td>Add before this node</td>
    <td></td>
</tr>
<tr>
    <td>mouseOver</td>
    <td>//span[contains(text(), 'Add before this node')]</td>
    <td></td>
</tr>
<tr>
    <td>mouseDown</td>
    <td>//span[contains(text(), 'Add before this node')]</td>
    <td></td>
</tr>
于 2014-11-29T10:28:06.523 回答