I'm new to the site and to WebDriver.
I am trying to work with a dynamic data table - HTML below
<div id="enquiry-header-grid-SalesTransactionEnquiry-enquiry-header-grid-wrapper" class="enquiry-kendo-grid-wrapper k-grid k-widget" data-role="grid" style="height: 456px;">
<div class="k-grid-content k-auto-scrollable" style="height: 428px;">
<table role="grid" tabindex="0" data-role="selectable" class="k-selectable" style="touch-action: none;">
<colgroup><col style="width:120px"><col style="width:120px"><col style="width:100px"><col style="width:60px"><col style="width:100px"><col style="width:105px"><col style="width:100px"><col style="width:120px"><col style="width:120px"><col style="width:100px"><col style="width:200px"><col style="width:120px"><col style="width:120px"><col style="width:60px"><col style="width:100px"><col style="width:100px"><col style="width:100px"><col style="width:100px"><col style="width:100px"><col style="width:120px"><col style="width:60px"><col style="width:100px"><col style="width:100px"> </colgroup>
<tbody role="rowgroup">
<tr data-uid="23f8ebd0-2c90-4728-9430-71376f2d10e3" role="row" class="k-state-selected" aria-selected="true">
<td class="col-align-left" role="gridcell"><a href="#" class="cell-popover" data-col-type="popover" data-col-name="ST_COPYCUST">MUFC</a></td>
<td class="col-align-left" role="gridcell">Manchester United</td>
<td class="col-align-right" role="gridcell">23/10/2017</td>
<td class="col-align-right" role="gridcell">1</td>
<td class="col-align-left" role="gridcell">Invoice</td>
<td class="col-align-left" role="gridcell">1000</td>
<td class="col-align-center" role="gridcell"><input type="checkbox" disabled="disabled"></td>
<td class="col-align-right" role="gridcell">5.00</td>
<td class="col-align-right" role="gridcell">1.00</td>
<td class="col-align-left" role="gridcell">SA</td>
<td class="col-align-left" role="gridcell"></td>
<td class="col-align-right" role="gridcell">6.00</td>
<td class="col-align-left" role="gridcell">0.00</td>
<td class="col-align-center" role="gridcell"><input type="checkbox" disabled="disabled"></td>
<td class="col-align-left" role="gridcell">2017</td>
<td class="col-align-left" role="gridcell">1</td>
<td class="col-align-right" role="gridcell">23/10/2017</td>
<td class="col-align-right" role="gridcell">23/10/2017</td>
<td class="col-align-left" role="gridcell"></td>
<td class="col-align-left" role="gridcell">0.00</td>
<td class="col-align-center" role="gridcell"><input type="checkbox" disabled="disabled"></td>
<td class="col-align-left" role="gridcell"></td><td class="col-align-left" role="gridcell"></td>
</tr>
<tr class="k-alt" data-uid="5a1d2279-5588-4c41-ab22-ce5361192a4c" role="row">
<td class="col-align-left" role="gridcell"><a href="#" class="cell-popover" data-col-type="popover" data-col-name="ST_COPYCUST">MUFC</a></td>
What I am trying to do is identify the row number based on the cell
<td class="col-align-left" role="gridcell">1000</td>
This column is always a unique value so is the ideal identifier for the row, so once I have the rowid I can then verify the values for all columns in the row.
From the research I have done myself I have got as far as below,
IWebElement elemTable = driver.FindElement(By.XPath("//div[@id='enquiry-header-grid-SalesTransactionEnquiry-enquiry-header-grid-wrapper']//table[1]"));
List<IWebElement> lstTrElem = new List<IWebElement>(elemTable.FindElements(By.TagName("tr")));
foreach (var elemTr in lstTrElem)
{
List<IWebElement> lstTdElem = new List<IWebElement>(elemTr.FindElements(By.TagName("td")));
foreach (var elemTd in lstTdElem)
{
IWebElement customer = elemTable.FindElement(By.XPath("//tr/td[contains(text(), '1000')]"));
...
Firstly I'm not confident that what I have is correct in terms of traversing all rows and columns for the table?
Then I'm struggling with how to proceed with getting the rowid to use to verify the other td's?
Am I using the right approach, and how do I move forward?
UPDATE
Thanks to Kate Paulk's answer below i have progressed slightly but am not hitting another roadblock I could do with some help on if possible.
IWebElement elemTable = driver.FindElement(By.Id("enquiry-header-grid-SalesTransactionEnquiry-enquiry-header-grid-wrapper")).FindElement(By.TagName("table"));
List<IWebElement> lstTrElem = new List<IWebElement>(elemTable.FindElements(By.TagName("tr")));
IWebElement row = lstTrElem.Where(item => item.Text.Contains( "1000" )).FirstOrDefault();
string rowid = row.GetAttribute("data-uid");
So this is now throwing the error,
Result Message: System.NullReferenceException : Object reference not set to an instance of an object.
Against the line
string rowid = row.GetAttribute("data-uid");
I think this is due to,
IWebElement row = lstTrElem.Where(item => item.Text.Contains( "1000" )).FirstOrDefault();
Again any help would be great, thanks in advance??