title: How to locate a text in a table and referring the element click on another element using Selenium in C#?
body: <p>I am having trouble working my head out, as what is the best way to search a specific <em>Text (CustId)</em> on a web table &amp; once I have found the search text then click on a <em>Select-Button</em> present at the end of the row. Now, I do have an ElementId for the table and progressive ElementId on each <em>Select-Button</em>
  Sample of the source code given below --</p>
  
  <pre><code>&lt;table class="w-table w-table-zebra w-table-hover" id="cust-found-table"&gt;
          &lt;tbody&gt;&lt;tr&gt;
            &lt;th class="w-table-header w-table-width-60"&gt;Cust name&lt;/th&gt;
            &lt;th class="w-table-header w-table-width-25"&gt;Cust Id&lt;/th&gt;
            &lt;th class="w-table-header w-table-width-15"&gt;&lt;/th&gt;
          &lt;/tr&gt;
          &lt;!----&gt;&lt;tr&gt;
            &lt;td class="w-table-row"&gt;Superman&lt;/td&gt;
            &lt;td class="w-table-row"&gt;12345&lt;/td&gt;
            &lt;td class="w-table-row text-center"&gt;
              &lt;button class="btn btn-sm w-btn-jetson px-4" type="button" id="cust-found-btn-0"&gt;Select&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
            &lt;td class="w-table-row"&gt;Spiderman&lt;/td&gt;
            &lt;td class="w-table-row"&gt;23456&lt;/td&gt;
            &lt;td class="w-table-row text-center"&gt;
              &lt;button class="btn btn-sm w-btn-jetson px-4" type="button" id="cust-found-btn-1"&gt;Select&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
            &lt;td class="w-table-row"&gt;Batman&lt;/td&gt;
            &lt;td class="w-table-row"&gt;34567&lt;/td&gt;
            &lt;td class="w-table-row text-center"&gt;
              &lt;button class="btn btn-sm w-btn-jetson px-4" type="button" id="cust-found-btn-2"&gt;Select&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;
  </code></pre>
  
  <p>This potentially may be a duplicate post, but couldn't find a similar one. Any help is appreciate. </p>
  
  <p>Go get started I have done as below but couldn't get this working --</p>
  
  <pre><code>var theSelector = "button[id*='" + cust-found-btn + "']";    
  IWebElement tableElement = driver.FindElement(By.Id("cust-found-table"));
          IList&lt;IWebElement&gt; tableRow = tableElement.FindElements(By.TagName("tr"));
          IList&lt;IWebElement&gt; rowTD;
          foreach (IWebElement row in tableRow)
          {
              rowTD = row.FindElements(By.TagName("td"));
  
              if (row.Text.Equals("searchtext"))
              {
                  driver.FindElement(By.Id("cust-found-btn")).Click();
              }
          }
  </code></pre>