title: Find an element by text and get xpath - selenium webdriver junit
body: <p>I have a table with 9 rows and 6 columns in my webpage. I want to search for a text "MakeGoodDisabled-Programwise_09_44_38_461(n)" and get the xpath of the cell. I have used the following but it fails because it is not able to find the text on the page. Can you please help? I am using Selenium Webdriver Junit to code this.</p>
  
  <pre class="lang-java prettyprint-override"><code>List &lt; WebElement &gt; links = driver.findElements(By.tagName("td"));
  
  Iterator &lt; WebElement &gt; itr = links.iterator();
  while (itr.hasNext()) {
   String test = itr.next().getText();
  
   if (test.equals("MakeGoodDisabled-Programwise_09_44_38_461(n)")) {
    String xpath = driver.findElement(By.name(test)).getAttribute("xpath");
    System.out.println(xpath);
   }
  }
  </code></pre>