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

Iteration index of Loop

5 Answers 134 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sachin
Top achievements
Rank 1
Sachin asked on 07 Jul 2014, 12:12 PM
Hi,

Can anyone tell me how get the iteration index of a loop in a coded step from inside the loop?

5 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 10 Jul 2014, 07:10 AM
Hello,

You can use this code to achieve that:

[CodedStep(@"New Coded Step")]
public void WebTest1_CodedStep()
{
    ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.LoopLogicalDescriptor loop = ExecutionContext.CurrentStep.AutoStep as ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.LoopLogicalDescriptor;
    Log.WriteLine("LoopCurrent: " + loop.LoopCurrent);
}

Note, you may need to add assembly reference to System.Runtime.Serialization.dll. On my Win 7 machine it is located here:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Serialization.dll

Regards,
Konstantin Petkov
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
neutcomp
Top achievements
Rank 2
answered on 08 Apr 2015, 02:37 PM

Hello,

This is just what i also want to use but I don't get it to work. I added the assembly and put the use statements in my code. It runs but I get an error see below. 

Hope you can help me out. 
Thanks

Exception thrown executing coded step: '[EnergieDirectScraper_DoAllYears] : Amount of Loops'.
InnerException:
System.NullReferenceException: Object reference not set to an instance of an object.
   at EnergieScraper.EnergieDirectScraper.EnergieDirectScraper_DoAllYears() in d:\TFS\Tools\RegressionTests\EnergieScraper\Energie direct\EnergieDirectScraper.tstest.cs:line 264

using System.Runtime.Serialization;
using ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors;
 
[CodedStep(@"Amount of Loops")]
        public void EnergieDirectScraper_DoAllYears()
        {
            LoopLogicalDescriptor loop = ExecutionContext.CurrentStep.AutoStep as LoopLogicalDescriptor;
            Log.WriteLine("LoopCurrent: " + loop.LoopCurrent);
        }

0
Ivaylo
Telerik team
answered on 10 Apr 2015, 06:37 AM
Hello Bjorn,

This is  a known issue which we currently fixed.

We've added executionContext.CurrentLogicalStep so that you can access both the coded and the logical parent/container step.

This will be included in the next internal build we are going to release at the end of this month.

Thank you for your patience and understanding.


Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
neutcomp
Top achievements
Rank 2
answered on 10 Apr 2015, 07:27 AM
Thanks for your feedback!
0
Ivaylo
Telerik team
answered on 10 Apr 2015, 11:01 AM
Hello Bjorn,

You are most welcome.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Sachin
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
neutcomp
Top achievements
Rank 2
Ivaylo
Telerik team
Share this question
or