System.NullReferenceException when trying to locate element

8 posts, 0 answers
  1. Jared
    Jared avatar
    5 posts
    Member since:
    Aug 2015

    Posted 02 Sep 2015 Link to this post

    Hi All,

     I have seen about 5 or 6 threads on this issue with no real solution or explanation given. I am in Visual Studio 2013 with Telerik Testing Framework. I am using examples provided by your support staff. I have added ArtOfTest.WebAii and Telerik.TestingFramework.Controls.KendoUI references to my solution. Then I have added the following namespaces to my test file (most of which I know are not necessary):

    using ArtOfTest.WebAii;
    using ArtOfTest.WebAii.Controls;
    using ArtOfTest.WebAii.Controls.HtmlControls;
    using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
    using ArtOfTest.WebAii.Core;
    using ArtOfTest.WebAii.ObjectModel;
    using NUnit.Framework;
    using Telerik.TestingFramework.Controls.KendoUI;

     

    namespace VNextTelerik
    {
        [TestFixture]
        public class Class1
        {
            public Manager myManager;
     
            [SetUp]
            public void TestFixtureSetUp()
            {
     
                // Initialize the settings
                Settings mySettings = new Settings();
     
                // Set the default browser
                mySettings.Web.DefaultBrowser = BrowserType.FireFox;
     
                // Create the manager object
                myManager = new Manager(mySettings);
     
                // Start the manager
                myManager.Start();
     
                
     
            }
             
            [Test]
            public void Kendo()
            {
     
                myManager.LaunchNewBrowser();
     
                myManager.ActiveBrowser.NavigateTo("http://demos.kendoui.com/web/numerictextbox/events.html");
     
                System.Threading.Thread.Sleep(5000);
     
                myManager.ActiveBrowser.RefreshDomTree();
     
                KendoInput textBox = myManager.ActiveBrowser.Find.ByExpression<KendoInput>("class=k-widget k-numerictextbox");
     
                textBox.TypeText("50");
            }
     
            [TearDown]
            public void TearDown()
            {
                // Shut-down the manager and do all clean-up
                myManager.Dispose();
            }
     
        }

    Every time it runs (KendoInput textBox = myManager.ActiveBrowser.Find.ByExpression<KendoInput>("class=k-widget k-numerictextbox");) this  returns null. I have tried many many things changing DomRefreshTree, waiting for element, longer thread.sleep (terrible solution). Ive tried to intialize the object as so(KendoInput textBox = new  KendoInput).What could be the issue?  Ive ran it at least 40 times and only one time did it actually find the object.  Ive attached the solution. In all the other threads with this problem your support staff runs peoples project and says it works. I am looking for a reason this may be happening and a possible solution.

     

    thanks

  2. Jared
    Jared avatar
    5 posts
    Member since:
    Aug 2015

    Posted 02 Sep 2015 in reply to Jared Link to this post

    Also can you send me a link to ticket 870203. the one post said there is an answer in that ticket but I cant find that ticket anywhere.
  3. Jared
    Jared avatar
    5 posts
    Member since:
    Aug 2015

    Posted 02 Sep 2015 Link to this post

    Update:

     This example from your admin returns null:

    KendoInput tBox = myManager.ActiveBrowser.Find.ByExpression<KendoInput>("class=k-widget k-numerictextbox");

    In this example the object can be found however I would like to use the first example:

    var te = myManager.ActiveBrowser.Find.ByExpression("class=k-widget k-numerictextbox");

  4. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 07 Sep 2015 Link to this post

    Hello Jared,

    You should look for the span instead for the input. This is due to kendo control specifics.

    Here is the correct code:

    KendoInput span = myManager.ActiveBrowser.Find.ByExpression<KendoInput>("class=k-widget k-numerictextbox");
    Assert.IsNotNull(span);
    span.TypeText("50");


    Thanks for your understanding.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  5. Jared
    Jared avatar
    5 posts
    Member since:
    Aug 2015

    Posted 08 Sep 2015 in reply to Ivaylo Link to this post

    Hi Ivaylo

     I have tried your suggestion and still get a null. I dont see how this is any different from what I tried other than naming the input a span instead of textbox. Everything else is the same.

     Thanks

    Jared

  6. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 09 Sep 2015 Link to this post

    Hello Jared,

    In the project provided the class you are using was different, after I changed it the test is executing successfully. Here is a short video demonstration (no audio) on how this works on my end. In order to investigate what is causing the behavior I will need to be able to reproduce the behavior on my end.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  7. Jared
    Jared avatar
    6 posts
    Member since:
    Sep 2014

    Posted 29 Sep 2015 Link to this post

    Thanks for all your help :)
  8. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 02 Oct 2015 Link to this post

    Hello,

    You are most welcome!

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top