0
votes

Thanks for taking the time to ready my questions. I need to mouseover then mousedown on an image (cog.png) for a specific node child represented by text to the right of an image. I can successfully Target the class but cannot work out how to target the image alone.

HTML, I want to target the cog.png near 'Australia'

<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>

Target code for Selenium IDE (which targets the full span, I just want the image cog.png)

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

I tried

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

Not surprisingly it was not specific enough and targeted the first instance of the image

Versions

  • Firefox 32.0.3
  • Selenium IDE: 2.7.0
1

1 Answers

0
votes

This is the code that I used to navigate on the dynatree, it wsa made more difficult as the first item was added as a child, the remainder added below or above the child. I kept track by creating 'counts' to determine at what point the items were added.

<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>