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

Retrieve [column,row] from KendoGridDataCell

3 Answers 147 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yan Jun
Top achievements
Rank 1
Iron
Veteran
Yan Jun asked on 13 May 2020, 04:04 AM
Hi, wondering if anyone knows how can I retrieve the [column,row] in KendoGridDataCell into coded step? I would like make a for loop on the columns and rows to verify the cell text. But I cannot find the column and row properties inside the Element repository. Please view the screenshots attached for more details.

3 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 13 May 2020, 01:17 PM

Hello Yan Jun,

You can iterate through the grid in a coded step and check for a specific content in any of the cells. Please check the example and details in this linked article and try it on your end.

I hope that will help you automate the test scenario. If you need further assistance, please share more details about your current code and what you want to achieve. I will do my best to help you automate it

Regards,
Plamen Mitrev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Yan Jun
Top achievements
Rank 1
Iron
Veteran
answered on 18 May 2020, 04:52 AM

Hi Plamen,

Thanks for the shared link. I have figured out how to loop through the table and verify each of the cell value now.

But I have another issue about verifying cell value. So I notice that if I use AssertContent to verify InnerText, if any 1 row of the value is found unmatched, then the execution of the loop in code will stop abruptly and will not continue to verify other rows.

May I know how do I overcome this issue? I would like to log error in the test result for that specific row that does not have matching value but at the same time continue to verify the other rows.

I have tried the following code but I keep having compilation error:

01.for(int i = 1; i <= itemCount; i++){
02.                      
03. Object cellValue = invoiceTable.Rows[i].Cells[qtyIndex].InnerText;
04.                      
05. if(Assert.IsFalse(cellValue.Equals("10.00" , ArtOfTest.Common.StringCompareType.Exact)) == true){
06.    Exception ex;
07.    throw new Exception("Row " + i + " ERROR: Quantity value does not match with Expected Result. \n\n" + ex.Message);
08. }
09.}

 

The compilation error:

error CS0176: Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead

 

Please kindly advise if my code is wrong somewhere.

Thank you.

Regards,

Yan Jun

0
Accepted
Plamen Mitrev
Telerik team
answered on 18 May 2020, 02:24 PM

Hi Yan Jun,

I am happy to know that you can loop through the table and verify the content and I will gladly help you with the follow up question.

The test execution will stop if any of the test steps fails, including coded steps that have Assert verifications. So, to work around this, you need to surround the verification in a try -> catch block. This way your code should continue to loop through the whole table and make the specified verification. Please check the sample code below, which is recorded against this application.

            foreach (HtmlTableRow r in Find.ByExpression<HtmlTable>("tagindex=table:0").AllRows)
            {
               foreach(HtmlTableCell c in r.Cells) 
                {
                    try {
                        c.AssertContent().InnerText(ArtOfTest.Common.StringCompareType.Exact, "text to compare");
                    } catch {
                        Log.WriteLine("Did not match.");
                    }
                }
            }

Please adjust the above code to match the test scenario on your end and do not hesitate to contact us again, if you need further assistance.

Regards,
Plamen Mitrev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Yan Jun
Top achievements
Rank 1
Iron
Veteran
Answers by
Plamen Mitrev
Telerik team
Yan Jun
Top achievements
Rank 1
Iron
Veteran
Share this question
or