title: selenium xpath, how to select last matching element in a table?
body: <p>Given</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;service1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;service2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;service3&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;blip&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>How can I select the last 'service-n' row when I don't know what n will be?
  I have tried adding <code>[last()]</code> but it didn't work.</p>
  
  <p>I have:</p>
  
  <pre><code>//table//tr//td[contains(text(),'service')]
  </code></pre>
  
  <p>but it selects the 1st row and I want the last one.<br>
  I can't use <code>tr[3]</code> because in reality the number of 'service-n' rows is dynamic and changes a lot.</p>