You can use the below method. Pass the value for what you are looking for like "Test Group 2". The below will loop through the table and stop on the value. From there, pass in the below to click the trash can.
tds[i + 4].Click();
So look at the columns and just count to the right (+) or left (-). If you wanted to click the assign button it should be:
tds[i + 2].Click();
If you had a button to the left of "Test Group 2" you would pass in:
tds[i - 1].Click();
Method:
public void ClickTableLink(string value)
{
var table = driver.FindElement(By.Id("assetGroup-table"));
foreach (var tr in table.FindElements(By.TagName("tr")))
{
var tds = tr.FindElements(By.TagName("td"));
for (var i = 0; i < tds.Count; i++)
{
if (tds[i].Text.Trim().Contains(value))
{
tds[i + 4].Click();
break;
}
}
}
}
You can use the below method. Pass the value for what you are looking for like "Test Group 2". The below will loop through the table and stop on the value. From there, pass in the below to click the trash can.
So look at the columns and just count to the right (+) or left (-). If you wanted to click the assign button it should be:
If you had a button to the left of "Test Group 2" you would pass in:
Method:
Not knowing what is under that fourth td I can't say for sure, but you can find it with an xpath that looks something like this.
You might have to specify which button since that edit button will be in the same td.