Skip to main content
4 of 5
Updated title to reflect problem in a more specific way, corrected spelling and punctuation, pretty-printed HTML

Cannot locate button with changing ID in Selenium

I am working on a project where I have to locate a button. I have used XPath for that, but button's id changes on every refresh, so I am facing problem witht that.. Below is HTML excerpt. Let me know can I identify that button so that it will not cause error even if id changes

<tr>
  <td/>
  <td>
    <div id="LoginButton" style="float: left;">
      <table style="width: auto;" id="ext-comp-1032" class="x-btn x-btn-noicon x-btn-over x-btn-focus" cellspacing="0">
        <tbody class="x-btn-small x-btn-icon-small-left">
          <tr>
            <td class="x-btn-tl">
              <i>&nbsp;</i>
            </td>
            <td class="x-btn-tc"/>
            <td class="x-btn-tr">
              <i>&nbsp;</i>
            </td>
          </tr>
          <tr>
            <td class="x-btn-ml">
              <i>&nbsp;</i>
            </td>
            <td class="x-btn-mc">
              <em class="" unselectable="on">
                <button class=" x-btn-text" id="ext-gen12" type="button">Login</button>
              </em>
            </td>
            <td class="x-btn-mr">
              <i>&nbsp;</i>
            </td>
          </tr>
          <tr>
            <td class="x-btn-bl">
              <i>&nbsp;</i>
            </td>
            <td class="x-btn-bc"/>
            <td class="x-btn-br">
              <i>&nbsp;</i>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </td>
</tr>
rohit ware
  • 155
  • 1
  • 3
  • 7