title: Can't get nth node in Selenium
body: <p>I try to write xpath expressions so that my tests won't be broken by small design changes. So instead of the expressions that Selenium IDE generates, I write my own.</p>
  
  <p>Here's an issue:</p>
  
  <pre><code>//input[@name='question'][7]
  </code></pre>
  
  <p>This expression doesn't work at all. Input nodes named 'question' are spread across the page. They're not siblings.</p>
  
  <p>I've tried using intermediate expression, but it also fails.</p>
  
  <pre><code>(//input[@name='question'])[2]
  error = Error: Element (//input[@name='question'])[2] not found
  </code></pre>
  
  <p>That's why I suppose Seleniun has a wrong implementation of XPath.</p>
  
  <p>According to <a href="http://www.w3.org/TR/xpath/#predicates" rel="noreferrer">XPath docs</a>, the position predicate must filter by the position in the <em>nodeset</em>, so it must find the seventh <code>input</code> with the name <code>'question'</code>. In Selenium this doesn't work. CSS selectors (<code>:nth-of-kind</code>) neither.</p>
  
  <p>I had to write an expression that filters their common parents:</p>
  
  <pre><code>//*[contains(@class, 'question_section')][7]//input[@name='question']
  </code></pre>
  
  <p>Is this a Selenium specific issue, or I'm reading the specs wrong way? What can I do to make a shorter expression?</p>