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

System.NullReferenceException: Object reference not set to an instance of an object.

5 Answers 691 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Naga
Top achievements
Rank 1
Naga asked on 05 Jul 2012, 01:17 PM
Hello:
    We have been encountered with the below error

System.NullReferenceException: Object reference not set to an instance of an object.


while we were trying to work with KendoGrids.This feature is quite inconsistent and unable perform required operation on the grids.This is hampering our automation as most of them are grids.Below is the code that we are using
  System.Threading.Thread.Sleep(1000);
KendoGrid grid=ActiveBrowser.Find.ById<KendoGrid>("assessmentWorklistViewInner"); 
foreach(KendoGridDataItem row in grid.DataItems)
{
   for (int i=1;i<=row.Cells.Count-1;i++)
    {
        var tempval=row.Cells[i].TextContent;
      Log.WriteLine(tempval);
        if (tempval=="Annual")
        {
              
           row.Cells[4].MouseClick();
           break;
            //cell.MouseClick(true);
        }
     
    }
      
}

5 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 06 Jul 2012, 06:12 PM
Hello Naga,

Which line is returning null? I adapted your code to execute against this Telerik Kendo demo site and it worked correctly.

You may try inserting an additional line to assert the grid is correctly found and is not null:

KendoGrid grid=ActiveBrowser.Find.ById<KendoGrid>("assessmentWorklistViewInner");
Assert.IsNotNull(grid);

You may also need to wait for the grid to exist before acting upon it. This is easiest done through a standard Wait For Exists step, but also can be done in code.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Ashish
Top achievements
Rank 1
answered on 16 Oct 2014, 05:35 AM
Hi Anthony,

I am facing a similar issue while finding an HtmlAnchor object and then clicking on it through code.

The anchor tag is inside a frame which is opened in an aspx page.

I have tried different solutions as below:

1.
HtmlAnchor crlink = new HtmlAnchor();
crlink = Manager.ActiveBrowser.Find.ByExpression<HtmlAnchor>("InnerText=~Complete Task","tagname=a","id=CloseLink");

2.
HtmlAnchor crLink = table.Find.ByAttributes<HtmlAnchor("href=http://www.google.com");
crLink.Click();

3.
HtmlAnchor CRLink = ActiveBrowser.Find.ById<HtmlAnchor>("CloseLink");
CRLink.Click(true);

4.
Element e1 = ActiveBrowser.Find.ById("CloseLink");
HtmlAnchor CRLink = new HtmlAnchor(e1);
CRLink.InvokeEvent(ScriptEventType.OnClick);
CRLink.MouseClick();

But each time I am getting the same exception as Naga.
Please help.
0
Ivaylo
Telerik team
answered on 20 Oct 2014, 10:48 AM
Hello,

I am closing this thread as a duplicate of ticket 870203.

Please refer to the ticket for more information.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Jared
Top achievements
Rank 1
answered on 02 Sep 2015, 02:11 PM
How do I find the ticket you reference above? Is there a link? I cannot find the ticket anywhere.
0
Ivaylo
Telerik team
answered on 07 Sep 2015, 08:29 AM
Hello Jared,

This is a private ticket, so you cannot access it.

If you are experiencing a problem please submit your own ticket with detailed information on the issue you are facing.

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