title: Selenium Xpath to find a table cells inside a div tag
body: <p>I have the following HTML code that I need to check if text exists within a table cell:</p>
  
  <pre><code>&lt;div class="background-ljus" id="AutoText"&gt;
    &lt;table class="topAlignedCellContent"&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;X1&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;X2&lt;/td&gt;
        &lt;/tr&gt; 
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;Y1&lt;/td&gt;
          &lt;td&gt;Y2&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;Z1&lt;/td&gt;
          &lt;td&gt;Z2&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have solved it like this: </p>
  
  <pre><code>By locator = getLocator(CommonConst.XPATH, "*//div[@" + type + "='" + anyName + "']");
    fluentWait(locator);
  
    WebElement div = getDriver().findElement(locator);
    List&lt;WebElement&gt; cells = div.findElements(By.tagName("td"));
    for (WebElement cell : cells) {
      if (cell.getText().contains(cellText)) {
        foundit = true;
      }
    }
  </code></pre>
  
  <p>But i think its a bit slow because I need to do this several times. 
  I tried to do this with only XPath but had no luck.</p>
  
  <pre><code>"*//div[@id='AutoText']//td[contains[Text(), 'celltext']]"
  "*//div[@id='AutoText']//table//tbody//tr[td//Text()[contains[., 'celltext']]"
  </code></pre>
  
  <p>Anyone have a suggestion about why my XPath isn't working? </p>