NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Meike_Rempe
Posts: 19
0 Kudos
Accepted Solution

change the step name dynamically

Hi

I'm trying to find out how to change the step name.

The problem is: When I call a sequence several times, I can find the names of the steps in the report for about 50 times.

So, what I want to do is: I want to pass a prefix for the step name on calling the sequence and add this prefix to each step name.

Do you have an idea how to do that?

Thanks a lot

Meike

Active Participant
j_dodek
Posts: 940

Re: change the step name dynamically

Hi Meike,

 

Just rename in PreExpression of the Step with Step.Name = "HelloWorld"

 

Hope this helps

 

Juergen

Member
Meike_Rempe
Posts: 19
0 Kudos

Re: change the step name dynamically

Hi Jürgen,

 

Thanks for your help!

It helps so far that now I can change the name. Very good :-). I wouldn't have found it myself.

But now, with evey call, the name becomes longer and longer ;-) (without the post-expression). And somehow the program seems to evaluate the post-expression before saving the name in the report. So I can choose between a super long name and the default name.

Here is what i wrote:

 

Pre-Expression:

Locals.iStepNameLength= Len(Step.Name),
Step.Name = Parameters.sCallerSequence+Step.Name

 

Post-Expression:smileyfrustrated:tep.Name = Right(Step.Name,Locals.iStepNameLength)

 

Meike

 

Active Participant
j_dodek
Posts: 940
0 Kudos

Re: change the step name dynamically

Hi Meike

 

Try to make it static.

Do not use Step.Name on the right side, use a local instead.

Step.Name = Parameters.sCallerSequence+Local.strName

 

If this will not help there is an other way to rename StepNames in report, by renaming it the ResultList.

but you need an additional step!!

 

 

Juergen

Member
Meike_Rempe
Posts: 19
0 Kudos

Re: change the step name dynamically

Hey Jürgen,

 

I had hoped that the solution would be easier :-(.

 

Thank you very much for your help. I learnd a lot!

 

Since my sequences are about 60 steps each (at the moment I have about 30 and it will be more), it's not so nice to save the step names in local variables. But it's also a lot of work to add additional test steps to change the names in the report.

Maybe I have to think about another way to get the structure clear in the report

 

Thanks again

 

Meike

Active Participant
warren_scott
Posts: 231
0 Kudos

Re: change the step name dynamically

Be careful with dynamically changing the name of the step at runtime -- it can cause interesting things to happen if you are not careful.

 

Consider adding information to Step.ReportText to add clarification of what is actually happening.

 

Also, you probably want to avoid using the expression Step.Name, as it is not necessairly the name of the step (especailly if you use this on a custom step type that has a variable you added called Step.Name) use instead NameOf(Step) or Step.AsPropertyObject.Name to help make sure you get the name of the step.

Member
Meike_Rempe
Posts: 19
0 Kudos

Re: change the step name dynamically

Hey Warren,

Thank you for the hint. Seems to be a good alternative to changing the step name.

Where can I add information to Step.ReportText? This variable does not seem to exist...(I tried to pass a value in the Post-Expressions field).

Meike

 

Active Participant
j_dodek
Posts: 940
0 Kudos

Re: change the step name dynamically

Hi Meike,

 

Try to use Step.Result.ReportText

 

Regards

Juergen

Member
Meike_Rempe
Posts: 19
0 Kudos

Re: change the step name dynamically

Hey Jürgen,

 

You're right, this returns a text in the protocol. Thank you! :smileyhappy:

 

Unfortunately it is hidden somewhere in the report when the teststep is passed (I use the xml-report with stylesheet "expand.xml").

I suppose I have to learn to create my own stylesheet or report model or whatever.

 

Thanks again

Meike

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page