This is a migrated thread and some comments may be shown as answers.

search for row and select checkbox in that row

2 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 10 Jul 2015, 06:46 PM

Hi there, 

 

I have a modal with a few rows of data and a check box on each row. I can't predict the order of rows, so the checkbox I want might be in different places at different times.

Can you help me figure out how to search for a text string within a row, and then select the checkbox on that row?

In the file attachment, I'd be searching for the string WV Corp.

2 Answers, 1 is accepted

Sort by
0
Justin
Top achievements
Rank 1
answered on 13 Jul 2015, 03:30 PM

Using this code

 

HtmlInputCheckBox inputcheck = Manager.ActiveBrowser.Find.ByXPath<HtmlInputCheckBox>("//td[text()='WV Corp']/preceding-sibling::td/td/input");
inputcheck.Click(true);

 

 throws this error

Exception thrown executing coded step: '[Test_Generate_Failed_COA_CodedStep] : Check 'MiddleContentCOA1SpecMatch1GrdSpecMatchRowSpecsCheckBox' to be 'True''.
Object reference not set to an instance of an object.

 

 

0
Ivaylo
Telerik team
answered on 15 Jul 2015, 11:57 AM
Hеllo,

I do not have access to the application so I cannot tell why this is not working, you may use the wrong XPath. You can also use a chained find expression instead of code and locate the checkbox you would like to click. Here is an article how you can proceed.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Justin
Top achievements
Rank 1
Answers by
Justin
Top achievements
Rank 1
Ivaylo
Telerik team
Share this question
or