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

Verifying Table cell value using assert

1 Answer 35 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 08 Jun 2018, 01:26 PM

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

 

 

 

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 13 Jun 2018, 11:49 AM
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!
Tags
General Discussions
Asked by
Rahul
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or