感谢您抽出宝贵时间准备我的问题。我需要鼠标悬停然后mousedown在图像(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']
毫不奇怪,它不够具体,并且针对图像的第一个实例
版本
答案 0 :(得分: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>