title: How to find tablerow element containing a certain span element with Selenium Webdriver
body: <p>I'm trying to write a method which takes a string variable (the name of a certain node) and gets the tr element containing an element with text same as the given string.</p>
  
  <p>First step would be to find an element in my html with</p>
  
  <pre><code>element.text = string
  </code></pre>
  
  <p>But i cant get the the    XPath    expression for that.</p>
  
  <p>I tried</p>
  
  <pre><code>  driver.FindElement(By.XPath(String.Format("//span[text()={0}]", &amp;stringVariable)));
  </code></pre>
  
  <p>This code throws an exception "cannot be evaluated or does not result in a Webelement."</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT:</p>
  
  <p>neither</p>
  
  <pre><code>//tr[span[text()= 'variableValue']] 
  </code></pre>
  
  <p>nor </p>
  
  <p><code>//tr[span[contains(text(), 'variableValue')]]</code></p>
  
  <p>works whereas</p>
  
  <pre><code>//tr[contains(text(), 'partOfVariableValueUntilFirstSpace')]
  </code></pre>
  
  <p>will work. I cannot explain why...</p>