search for row and select checkbox in that row

3 posts, 0 answers
  1. Justin
    Justin avatar
    2 posts
    Member since:
    Mar 2015

    Posted 10 Jul 2015 Link to this post

    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. Justin
    Justin avatar
    2 posts
    Member since:
    Mar 2015

    Posted 13 Jul 2015 Link to this post

    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.

     

     

  3. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 15 Jul 2015 Link to this post

    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!
Back to Top