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

NullReferenceException on coded HtmlControl find

4 Answers 16 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bret
Top achievements
Rank 1
Bret asked on 13 Apr 2016, 09:03 PM

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)

 

4 Answers, 1 is accepted

Sort by
0
Bret
Top achievements
Rank 1
answered on 14 Apr 2016, 07:47 PM

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

Manager.ActiveBrowser.RefreshDomTree

0
Boyan Boev
Telerik team
answered on 15 Apr 2016, 02:54 PM
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!
0
evan
Top achievements
Rank 1
answered on 30 Oct 2018, 05:50 AM

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

0
Daniel Djambov
Telerik team
answered on 01 Nov 2018, 11:49 AM
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!
Tags
General Discussions
Asked by
Bret
Top achievements
Rank 1
Answers by
Bret
Top achievements
Rank 1
Boyan Boev
Telerik team
evan
Top achievements
Rank 1
Daniel Djambov
Telerik team
Share this question
or