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

6 posts, 1 answers
  1. Naga
    Naga avatar
    15 posts
    Member since:
    Apr 2012

    Posted 05 Jul 2012 Link to this post

    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);
            }
         
        }
          
    }
  2. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 06 Jul 2012 Link to this post

    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
  3. Ashish
    Ashish avatar
    1 posts
    Member since:
    Oct 2014

    Posted 16 Oct 2014 in reply to Anthony Link to this post

    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.
  4. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 20 Oct 2014 Link to this post

    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!
  5. Jared
    Jared avatar
    5 posts
    Member since:
    Aug 2015

    Posted 02 Sep 2015 Link to this post

    How do I find the ticket you reference above? Is there a link? I cannot find the ticket anywhere.
  6. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 07 Sep 2015 Link to this post

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