NullReferenceException on coded HtmlControl find

5 posts, 0 answers
  1. Bret
    Bret avatar
    2 posts
    Member since:
    Apr 2016

    Posted 13 Apr 2016 Link to this post

    Hi

    I receive the error "System.NullReferenceException: Object reference not set to an instance of an object." on a coded step that logs a user out of web application in step 5, and then waits until the "thank you" text is displayed on the subsequent page until continuing with the script. The error is thrown on line 8. I construct the ThankYouSignOut object in line 7 almost exactly the same as the SignOutLink in step 2, so I'm at a loss as to why it's passing on step 2-5, but failing on 8. Any help would be appreciated!

     

    1.ActiveBrowser.Window.SetFocus
    2.Dim SignOutLink AS HtmlAnchor = ActiveBrowser.Find.ByExpression(Of HtmlAnchor)(new HtmlFindExpression("tagname=a", "href=~logout"))
    3.SignOutLink.Wait.ForExists(30000)
    4.SignOutLink.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop)
    5.SignOutLink.MouseClick
    6.ActiveBrowser.Window.SetFocus
    7.Dim ThankYouSignOut AS HtmlControl = ActiveBrowser.Find.ByExpression(Of HtmlControl)(new HtmlFindExpression("tagname=p","TextContent=^Thank you for using"))
    8.ThankYouSignOut.Wait.ForExists(30000)

     

  2. Bret
    Bret avatar
    2 posts
    Member since:
    Apr 2016

    Posted 14 Apr 2016 in reply to Bret Link to this post

    Nevermind. Of course as soon as I post to the forum I find the answer to my question.

    Manager.ActiveBrowser.RefreshDomTree

  3. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 15 Apr 2016 Link to this post

    Hi Bret,

    Happy to hear that!

    If you need further assistance please let us know.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  4. evan
    evan avatar
    2 posts
    Member since:
    Oct 2018

    Posted 30 Oct 2018 Link to this post

    To fully understand why a NullReferenceException is thrown, it is important to know the difference between value types and reference types.

    So, if you're dealing with value types, NullReferenceExceptions can not occur. Though you need to keep alert when dealing with reference types!

    Only reference types, as the name is suggesting, can hold references or point literally to nothing (or 'null'). Whereas value types always contain a value.

    Reference types (these ones must be checked):

    dynamic
    object
    string

    Value types (you can simply ignore these ones):

    Numeric types
    Integral types
    Floating-point types
    decimal
    bool
    User defined structs

  5. Daniel Djambov
    Admin
    Daniel Djambov avatar
    84 posts

    Posted 01 Nov 2018 Link to this post

    Hi,

    Thank you for the feedback on this issue.

    To my understanding there is currently no problem with the product that requires additional input.

    If my assumption is wrong, please let me know how we can help you further.

    Best Regards,
    Daniel Djambov
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top