如果我可以在同一行中找到文本字符串,如何识别 table 中的复选框?

How to identify a checkbox in a table if I can find a text string on the same row?

我正在尝试修复损坏的测试。我正在使用 VS2010 C# 和 Webaii (Telerik) 来自动化测试。

我在网页中得到了一个 table 并且有 10 行(带分页)每行包含 10 列(假设列名称为 A,B,C,D,E...)列 "C" 那里有一个复选框(没有标签),"E" 列有一个超链接,下面是代码,当我 运行 它找不到申请号

旁边的复选框时
string applicationNumber="A2341"
StringBuilder buffer = new StringBuilder();
buffer.Append("//a[contains(text(),'").Append(applicationNumber).Append("')]/../..//input[@type='checkbox']");
Generic.Find.ByXPath<HtmlInputCheckBox>(buffer.ToString()).Check(true, true); 

当我 运行 它找不到申请号旁边的复选框但是如果我使用下面的代码然后在该页面上它单击第一个复选框而不是我的申请号对应的复选框

Generic.Find.ByXPath<HtmlInputCheckBox>("//input[contains(@type,\"checkbox\")]").Check(true, true);

我的代码有什么问题

我的解决方案是

StringBuilder buffer = new StringBuilder();
buffer.Append("//a[contains(text(),'").Append(applicationNumber + "')]");
String id = Generic.Find.ByXPath(buffer.ToString()).IdAttributeValue.Split(new char[] { ':' })[2];
Generic.Find.ById<HtmlInputCheckBox>("dashboardForm:applicationTaskTable:" + id + ":application_checkbox").Check(true, true);