title: How to select second div element in XPath?
body: <p>I'm trying to select the <code>div</code> that's highlighted with the blue bar:</p>
  
  <p><a href="https://i.stack.imgur.com/OVFUv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OVFUv.png" alt="enter image description here"></a></p>
  
  <p>It's the second <code>div</code> on the page that contains the text <code>"All"</code>, so my attempt is as follows:</p>
  
  <pre><code>all_button = driver.find_element_by_xpath("//div[contains(., 'All')][2]")
  </code></pre>
  
  <p>For some reason, when I run my program, this selects the <code>div</code> that's highlighted in yellow.  I've tried using <code>string()</code> and <code>text()</code> in place of a period within the <code>contains()</code> section, but it yields the same result.  Any ideas?</p>