title: How to select Nth element in XPath with multilevel nesting
body: <p>We can use :position() in xpath to retreive nth element in simple HTML block like this:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;first&lt;/li&gt;
  &lt;li&gt;second&lt;/li&gt;
  &lt;li&gt;third&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>We can query element by <code>//li[position()=2]</code> but this won't work in this situation:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;b&gt;&lt;li&gt;first&lt;/li&gt;&lt;/b&gt;
  &lt;b&gt;&lt;li&gt;second&lt;/li&gt;&lt;/b&gt;
  &lt;b&gt;&lt;li&gt;third&lt;/li&gt;&lt;/b&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>And we have to use <code>//b[position()=2]/li</code>.</p>
  
  <p><strong>The problems is that I want to create a XPath rule for nth-element for my selenium test, which will no be tight coupled with decoarational tags</strong>. I need a XPath that will work even when mu nth-elements will be decorated with additional tags.</p>
  
  <p>I know that for testing purposes I can change backend logic to provide additional testing handles in html like data-* attributes, but suppose that I can't change code of app under test.</p>
  
  <p>So, I'm searching for XPath query like: <strong>"Give me third <code>&lt;li&gt;</code> element, wherever it lays in specified page (or page block) even if it is multiply nested"</strong></p>