Hi,
I have a requirement that i want to read the excel data based on the test case name.
i have reusable actions i want to get the current test case name using code in the reusable actions then get the data from the excel based on the test cases name.
Can u please help me out
How to get test case name using code, while execution
-
- Posts: 21
- Joined: Wed Dec 07, 2011 2:54 pm
- Location: India
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to get test case name using code, while execution
Hi,
the test case name can be accessed using following code snippet within your user code modules:
Tobias
Ranorex Support Team
the test case name can be accessed using following code snippet within your user code modules:
String name = TestCase.Current.Name;Kind regards,
Tobias
Ranorex Support Team
-
- Posts: 21
- Joined: Wed Dec 07, 2011 2:54 pm
- Location: India
Re: How to get test case name using code, while execution
Thanks for the code, worked perfectly.
Thanks
Ajay
Thanks
Ajay
-
- Posts: 2
- Joined: Mon Feb 25, 2013 1:09 pm
Re: How to get test case name using code, while execution
Hi,
I tried to use TestCase.Current.Name in my user code module. But I'm getting the below error. What could be the possible reason?
Object reference not set to an instance of an object.
Show/Hide Stacktrace
at SampAutomation.supportlibraries.ExecuteTest.Ranorex.Core.Testing.ITestModule.Run() in c:\Users\pceqa\Documents\Ranorex\Core\SampAutomation\SampAutomation\supportlibraries\ExecuteTest.cs:line 53 at Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)
Thanks,
-Bala.
I tried to use TestCase.Current.Name in my user code module. But I'm getting the below error. What could be the possible reason?
Object reference not set to an instance of an object.
Show/Hide Stacktrace
at SampAutomation.supportlibraries.ExecuteTest.Ranorex.Core.Testing.ITestModule.Run() in c:\Users\pceqa\Documents\Ranorex\Core\SampAutomation\SampAutomation\supportlibraries\ExecuteTest.cs:line 53 at Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)
Thanks,
-Bala.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to get test case name using code, while execution
Hello,
The reference to this object is not available if you run a code or recording module only.
You might need to run the whole TestCase to get the current name of it.
Could you please try to run the TestCase?
If it is still not working, could you please post the code you use for it.
Thank you.
Regards,
Markus (T)
The reference to this object is not available if you run a code or recording module only.
You might need to run the whole TestCase to get the current name of it.
Could you please try to run the TestCase?
If it is still not working, could you please post the code you use for it.
Thank you.
Regards,
Markus (T)
-
- Posts: 2
- Joined: Mon Feb 25, 2013 1:09 pm
Re: How to get test case name using code, while execution
Thanks Markus for your reply.
As you suggested, I have called at test case level. It works fine.
Thanks,
-Bala.
As you suggested, I have called at test case level. It works fine.
Thanks,
-Bala.
Re: How to get test case name using code, while execution
I tried to access the testcase name from code.
Is that possible?
I tried Using this code.
but it says that The name 'TestCase' does not exist in the current context (CS0103) -
C:\Users\parnepalli\Documents\Ranorex\RanorexStudio Projects\IDSys\IDSys\MailLogger.cs:329,58
I wanna show the test case name in my mail.
Is that possible?
I tried Using this code.
Code: Select all
TestCase.Current.Name
C:\Users\parnepalli\Documents\Ranorex\RanorexStudio Projects\IDSys\IDSys\MailLogger.cs:329,58
I wanna show the test case name in my mail.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to get test case name using code, while execution
Hi,
Did you add the correct namespace to you class "using Ranorex.Core.Testing;"?
Regards,
Markus
Did you add the correct namespace to you class "using Ranorex.Core.Testing;"?
Regards,
Markus