Verifying Table cell value using assert

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    12 posts
    Member since:
    Mar 2018

    Posted 08 Jun Link to this post

    Hi,

    I am trying to verify a particular cell value in a table. I went through similar questions asked in the past to get the solution.

    My "Build Succeded", but "step failed"

    HtmlTable T1 = ActiveBrowser.Find.ByXPath<HtmlTable>("//*[@id='ProgramGrid']/div[2]/table/tbody");
    HtmlTableCell C1 = T1.Find.ByXPath<HtmlTableCell>("//*[@id='ProgramGrid']/div[2]/table/tbody/tr[2]/td[5]");

    Assert.IsTrue(C1.TextContent.Equals("Irish Dunlap"));

     

     

     

  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    938 posts

    Posted 13 Jun Link to this post

    Hi Rahul,

    Thank you for the shared details. 

    Probably any of the elements is not located on the page and the Assert statement is failing. You could double check the execution log where further details will be listed about the exception thrown. 

    Since you need to use code to automate your actions I would like to share with you what methods you could use to locate elements on page. Please note we do not recommend using Xpaths as these might be easily changes with a minor update in the application under test. 

    Another useful advice will be to insert Assert statements after each line where you locate an element - that way you will easily find out which is the element which is not properly located. 

    In addition I noticed that the Xpaths visible partially are both relative to a grid which contains the html table. If you are locating the table cell under the html table you probably need to change that Xpath as well. Of course, if you decide to stick to Xpath usage. 

    I hope the information will be useful to you. Though let me know in case of further questions. 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top