11 Answers, 1 is accepted
My apologies, I accidentally posted before I was finished. I will try again ..
Hi,
In my project I have two tests, one for 'Accounts' and another for 'Advanced Find'
The 'Accounts' test has a coded step..
public void SelectAccountTypeByName(String typeName, Browser xframe)
{
some code
Log.Writeline("hello world");
}
When my 'Accounts' test executes this coded step, it executes successfully.
However, if in the 'Advanced Find' test I attempt to use this coded step as follows..
Accounts xaccount = new Accounts();
xaccount.SelectAccountTypeByName("random", Account_contentIFrame0);
The 'Log.WriteLine("hello world")' results in..
System.NullReferenceException: Object reference not set to an instance of an object.
at ArtOfTest.WebAii.Design.BaseWebAiiTest.get_Log()
at TestProject2.Accounts.SelectAccountTypeByName(String typeName, Browser xframe) in f:\New folder\Test Studio Projects\TestProject2\Accounts\Accounts.tstest.cs:line 148
at TestProject2.Advanced_Find.Select_Type_Random1() in f:\New folder\Test Studio Projects\TestProject2\Advanced Find\Advanced Find.tstest.cs:line 201
If I comment out the Log.WriteLine, the coded step executes fine.
Your help would be appreciated.
thanks,
dan
Is the Log.WriteLine in a coded step (in the second test)?
Is there a chance you can send us your project so we can review it?
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik by Progress
Test Studio Trainings
Hi Boyan,
Yes, it is in a coded step. I've attached the project.
thx,
dan
I assume that the issue is that Log.WriteLine method accept only sting so you should change your code as follows:
Log.WriteLine(
"Select option: "
+newIndexx.ToString()+
" of "
+AccounttypeISelect.Options.Count.ToString());
However I cannot confirm this since I cannot execute your test.
The other options is that some of the variables you want to WriteLine does not exists in the current context.
Hope that helps.
Regards,
Boyan Boev
Telerik by Progress
Test Studio Trainings
Hi Boyan,
Thanks for your suggestion, but the problem is not with the variables I'm attempting to log. I get the exception when using just Log.WriteLine("Hello world").
As I noted before, if the coded step includes 'Log.Writeline("hello world")', then the 'Accounts' test executes the coded step successfully. But, if in the 'Advanced Find' test I attempt to use this coded step as follows..
Accounts xaccount = new Accounts();
xaccount.SelectAccountTypeByName("random", Account_contentIFrame0);
The presence of 'Log.WriteLine("hello world")' results in the exception. If I comment it out, then xaccount.SelectAccountTypeByName("random", Account_contentIFrame0) also executes successfully.
I am not able to reproduce this issue. I am able to start every test from the project you've sent me.
See this video for a demonstration.
Could you please creating a new test and copy all the steps from the previous one to the new one?
Please record a short video demonstrating the exact issue.
Thank you!
Regards,
Boyan Boev
Telerik by Progress
Test Studio Trainings
I’ve attached a simplified project that demos the issue.
You’ll notice WebTest1 passes, but WebTest2 fails on Log.WriteLine(“hello world”) ...
Failure Information: ~~~~~~~~~~~~~~~Exception thrown executing coded step: 'New Coded Step'.InnerException:System.NullReferenceException: Object reference not set to an instance of an object. at ArtOfTest.WebAii.Design.BaseWebAiiTest.get_Log() at LogWrteLineIssue_Demo.WebTest1.enterSearchText(Browser xbrowser) in c:\Users\odacrd\Documents\Test Studio Projects\LogWrteLineIssue_Demo\WebTest1.tstest.cs:line 54 at LogWrteLineIssue_Demo.WebTest2.WebTest2_CodedStep() in c:\Users\odacrd\Documents\Test Studio Projects\LogWrteLineIssue_Demo\WebTest2.tstest.cs:line 53
Once you comment out the Log.WriteLine(“hello world”) in WebTest1.tstest.cs:line 54, then both WebTest1 and WebTest2 pass.
Thanks,
dan
Now I understand what is going on exactly.
Unfortunately you cannot crate instances of other tests and call it like this. There is no Manager initialized e.t.c.
You can create a standalone code file where you can implement your own methods and call them in any test you want.
I have modified the project you have sent me with a such file for a demonstration.
Hope that helps.
Regards,
Boyan Boev
Telerik by Progress
Test Studio Trainings
Excellent! Thanks Boyan. I'll give that a try.
Cheers,
dan
You are most welcome.
Please give that a try and let me know the results.
Regards,
Boyan Boev
Telerik by Progress
Test Studio Trainings