I am working with the following html table,
<tbody role="rowgroup">
<tr data-uid="d4d2114f-2aaf-4498-977b-ae5b8c16618c" role="row" class="Standard k-state-selected" aria-selected="true">
<td role="gridcell" id="sublist-ComplianceTaskUserLinksSublist-sublist-grid-wrapper_active_cell" class="k-state-focused" aria-describedby="7f2be8c4-c05c-4959-8b6e-26f26ffd343c sublist-ComplianceTaskUserLinksSublist-sublist-grid-wrapper_active_cell">USER5</td>
<td role="gridcell">USER5 </td></tr>
</tbody>
There is only one row however this will not always be the case so i have wrote a method which identifies a rows data-uid based on a cell value which is,
IWebElement tablebody = LinkedUserGroupComplianceTaskUserLinkTable.FindElement(By.TagName("tbody"));
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.TagName("tr")));
List<IWebElement> rows = new List<IWebElement>(tablebody.FindElements(By.TagName("tr")));
IWebElement row = rows.Where(item => item.Text.Contains(loginname)).FirstOrDefault();
string rowid = row.GetAttribute("data-uid");
However when i run a test containing this method i get exception,
WebDriverTimeoutException
against wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.TagName("tr")));
I have used the above method elsewhere with success.
I have added a thread sleep to the method instead of the line throwing the exception which when ran works - code below,
IWebElement tablebody = LinkedUserGroupComplianceTaskUserLinkTable.FindElement(By.TagName("tbody"));
Thread.Sleep(3000);
List<IWebElement> rows = new List<IWebElement>(tablebody.FindElements(By.TagName("tr")));
IWebElement row = rows.Where(item => item.Text.Contains(loginname)).FirstOrDefault();
string rowid = row.GetAttribute("data-uid");
I'm looking for some help in how to refactor the method so i don't have to use the Thread.Sleep() or any suggestions as to why my original method is throwing the exception?