title: How to find <span> Element within <tr> by XPath
body: <p>My HTML Code looks like this:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;div&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;table&gt;
                  &lt;tbody id=a&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;div&gt;
                                  &lt;span&gt;
                                     some Text
                                  &lt;/span&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;div&gt;
                                  &lt;span&gt;
                                     some Text2
                                  &lt;/span&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;div&gt;
                                  &lt;span&gt;
                                     some Text3
                                  &lt;/span&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                &lt;/tbody&gt;
         &lt;/table&gt;
     &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm trying to select each of the span elements by their text. I'm able to select the tbody by id. I Tried this:</p>
  
  <pre><code>tbody.FindElement(By.XPath(String.Format(".//span[contains(text(), {0}))]", &amp;var)));  
  (var = somex0020Text)
  </code></pre>
  
  <p>but this always returns the first <code>&lt;span&gt;</code> element in my table.</p>
  
  <p>I also tried:</p>
  
  <pre><code>tbody.FindElements(By.XPath(String.Format(".//span[contains(text(), {0}))]", &amp;var))); 
  </code></pre>
  
  <p>which returned a list containing every single <code>&lt;span&gt;</code> element in my table, and I don't know why.</p>
  
  <p>I also don't understand why </p>
  
  <pre><code>tbody.FindElement(By.XPath(String.Format(".//span[text() =  {0})]", &amp;var)));   
  </code></pre>
  
  <p>throws an Element not found Exception, when the contain method returns a <code>&lt;span&gt;</code> element with just the same text.</p>