Result Message:
Test method InternalPortalTests.AAALoginToImpersonation.AAALoginUsingImpersonation threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
The Element definition was:
public ArtOfTest.WebAii.Controls.HtmlControls.HtmlButton IAgreeButtonTag
{
get
{
return _manager.ActiveBrowser.Find.ByExpression<ArtOfTest.WebAii.Controls.HtmlControls.HtmlButton>("tagname=button", "InnerText='I Agree'");
}
}
The line that called the element is:
allpages.IAgreeButtonTag.Click(false);
The Dom Section I'm using is attached.
Any ideas?
I'm bewildered by how hard it is to get any TestStudio test converted to MStest to work.
6 Answers, 1 is accepted
Thank you for reaching us out.
I suppose you have converted the Test Studio test to MSTest and since then you are getting this NullReference exception. As of the details shared it seems that eiither allpages is not generated as you expected it to or the button itself is null.
To be able to better identify what the problem could be I would like to kindly ask you to share the project in question for further investigation. If you would need a shared folder to upload it please let me know.
Thanks!
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings
Hi Elena, I'm trying to strip down the project to give you some pieces of it, to look at, but I can't have you run it against our product so I'm not sure how much use that is.
I'm much more worried about:
https://www.telerik.com/forums/unable-to-run-the-automated-tests-using-mstest-exe
Elena,
I can give you copies of the test class and the pages class - I've had to put place holders in for the url and the path to the Newtonsoft package. But I will need to get a shared folder.
I can't send you all of the project, there is too much proprietary information in there.
Oddly, when we do the conversion to an mstest in the TestStudio project the workarounds mentioned in https://www.telerik.com/forums/unable-to-run-the-automated-tests-using-mstest-exe works to get that reference to work, but not in a new unit test project.
LoginUsingImpersonationUnitTestTelerik.cs:line 256
Result Message:
Test method InternalPortalTests.AAALoginToImpersonationTelerik.AAALoginUsingImpersonationTelerik threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Thank you for the additional details listed.
The bottleneck here is that you are trying to directly copy the Test Studio tests to unit tests. This will not work as the elements are in the Pages.cs file and there is no way to export or convert that to be usable in a unit test project.
If you would like to use unit tests and import the testing framework dlls you would need to locate the elements on page independently. Here are some useful articles which will help you understand the idea:
Finding Page Elements
Find Expressions
DOM Navigation
I hope this will be useful to you. Though if you would need further assistance please let me know. Thanks!
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings
I'm confused here. I know that depending on Pages.g.cs won't work in a unit test, but I have instead created a page class that just has the same finds in it. Based on reading those documents the finds seemed correct to me. If the elements are defined as members of the page class and I'm using the same find logic, why would I be having problems? I didn't just rename Pages.g.cs, I instead created a whole new class. Maybe if you could send me the shared folder I can show you.
Please find a folder at your disposal here. Let me review the project to be able to provide further comments on the topic.
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings