0

I am trying to fix a broken test. I am using VS2010 C# with Webaii (Telerik) to automate the test.

I got a table in webpage and has 10 rows (with pagination) each row contains 10 columns (assume columns names as A,B,C,D,E...) in Column "C" a checkbox is there (no label) and column "E" got a hyperlink the below is the code, when I run it fails to find checkbox next to application number

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); 

when I run it fails to find checkbox next to application number But if I use the below code then on that page it clicks the first checkbox but not the corresponding check box to my application number

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

whats wrong with my code

user790049
  • 1,154
  • 1
  • 9
  • 21

1 Answers1

0

my solution is

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);
user790049
  • 1,154
  • 1
  • 9
  • 21