-1

I am stuck at a point , where I have to click on a particular image icon to expand the selection.

This is the HTML code for that

<table role="presentation" class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="width:1043px;height:21px;">
  <tbody role="presentation">
    <tr role="presentation">
      <td id="x-auto-354" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:number x-grid-cell-first  x-treegrid-column" style="width:202px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:number">
          <div role="presentation" unselectable="on" class="x-tree3-el">
            <img src="http://plmtest.lenovo.com/Windchill/gwt/com.ptc.windchill.wncgwt.WncGWT/clear.gif" style="height: 18px; width: 18px;">
            <img src="http://plmtest.lenovo.com/Windchill/gwt/com.ptc.windchill.wncgwt.WncGWT/clear.cache.gif" style="width: 16px; height: 16px; background: url(http://plmtest.lenovo.com/Windchill/gwt/com.ptc.windchill.wncgwt.WncGWT/C4EA130FD0ED44BE513FEEDDE13614DA.cache.png) no-repeat -34px 0px"
            border="0"><span></span><span class="cat-icons-tree"><img src="http://plmtest.lenovo.com/Windchill/gwt/com.ptc.windchill.wncgwt.WncGWT/clear.cache.gif" style="width: 16px; height: 16px; background: url(http://plmtest.lenovo.com/Windchill/./wtcore/images/part.gif) no-repeat 0px 0px;" id="miniInfo_OR:wt.part.WTPart:207216019841642" border="0"><span></span></span>
            <span
            unselectable="on" class="x-tree3-node-text">86000606</span>
          </div>
          <div role="presentation" unselectable="on" id="x-auto-224" class="x-tree3-node"></div>
        </div>
      </td>
      <td id="x-auto-355" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:infoPageAction   " style="width:32px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:infoPageAction">
          <div title="View Information">
            <a href="app/#ptc1/tcomp/infoPage?oid=VR:wt.part.WTPart:20662978987" target="_top">
              <img src="http://plmtest.lenovo.com/Windchill/netmarkets/images/details.gif" class="gwt-Image">
            </a>
          </div>
        </div>
      </td>
      <td id="x-auto-356" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:state   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:state">Production Released</div>
      </td>
      <td id="x-auto-357" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Link:quantityAmount   " style="width:57px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Link:quantityAmount">1</div>
      </td>
      <td id="x-auto-358" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:IBA|basic_name   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:IBA|basic_name">86 PART</div>
      </td>
      <td id="x-auto-359" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:IBA|LocationCode   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:IBA|LocationCode">DSWP</div>
      </td>
      <td id="x-auto-360" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:IBA|UsageCode   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:IBA|UsageCode">DC86</div>
      </td>
      <td id="x-auto-361" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Link:lineNumber   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Link:lineNumber">40</div>
      </td>
      <td id="x-auto-362" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:name   " style="width:182px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:name">Warranty Common Group</div>
      </td>
      <td id="x-auto-363" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:docstructure_status   " style="width:17px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:docstructure_status"></div>
      </td>
      <td id="x-auto-364" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:version   " style="width:102px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:version">K.5 (Design)</div>
      </td>
      <td id="x-auto-365" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Link:replacementStatus   " style="width:17px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Link:replacementStatus"></div>
      </td>
      <td id="x-auto-366" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:IBA|bac_code   " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:IBA|bac_code"></div>
      </td>
      <td id="x-auto-367" role="gridcell" class="x-grid3-col x-grid3-cell x-grid3-td-Child:containerName x-grid3-cell-last  " style="width:62px;">
        <div unselectable="on" class="x-grid3-cell-inner cat-x-grid3-cell-inner x-grid3-col-Child:containerName">CTO_DT</div>
      </td>
    </tr>
  </tbody>
</table>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
test D
  • 11
  • 6

1 Answers1

0

Try the following code:

driver.findElement(By.xpath("//div[@class='x-tree3-el']/img[1]"));

If not working, try as below:

driver.findElement(By.xpath("//div[@class='x-tree3-el' and @role='presentation']/img[1]"));

Screenshot reference:

enter image description here

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
  • I verified with updated HTML for table (in Firebug plugin in Firefox). It is still working for me. Please check whether the `table` is child of an `iframe` tag. If yes, then you need to switch to the frame first and then find the element. more details about switching b/w frames here http://stackoverflow.com/a/40759300/2575259 – Naveen Kumar R B Feb 14 '17 at 07:09
  • it is not inside an iframe – test D Feb 14 '17 at 12:04
  • could you plz share the screenshot of the FirePath of your attempt? like same as mine in the answer. – Naveen Kumar R B Feb 14 '17 at 12:10
  • I have to expand the number 86000606 in the pic http://imgur.com/sDDTu6B – test D Feb 15 '17 at 05:43
  • what is the issue? element not identified? given details are not helpful for me to identify your issue – Naveen Kumar R B Feb 15 '17 at 06:03
  • Now, can you please share the screenshot of firefox - highlighting the Firebug with the Xpath you tried? (need similar screenshot as the one posted in answer, I hope this time you understand :), otherwise, it is difficult to help you) – Naveen Kumar R B Feb 15 '17 at 06:09