I have a parameter file with the following structure:
param1
a = 5
b = 10
param2
a = 11
b = 12
I need a variable that contains "param1 param2", just those 2 names, not their values, not the list of sub-parameters, just the names of the 2 major categories.
Can that be done?
Thank you
Answer by dommarajurakesh · Sep 13, 2016 at 07:19 PM
I don't think so we have an direct option to do this in iTest. But using the "readfile" command we can do this.
Read the parameter file using the readfile command in a testcase. It will read the xml data of parameter file.
Create a pattern response map file (using the regular expressions in anchor) for xml data to get the only main parameter names.
Attached are the required files for your reference. forum-post.zip
Thank you for the quick answer.
I did this, but in another manner, it's kind of a trick, but it works.
I did a for loop, and check if the variable a is present. If it's present then I add paramX to a list. The only downside to this is that I have to give a predefined value for the for loop and in case I have more parameters then I have defined for the loop then I might not get all of them, but that's manageable.
Have a nice day
Answer by Malcom Terry · Apr 07, 2020 at 09:07 PM
Use an Xpath query. No response map to maintain. Add an analysis rule to the readFile step. Use query "names(mapped/Xml/ParameterTree/parameters/parameters/*)". See example:
Assuming this is your parameter structure:
Test case:
Get parameter names 1 Answer
HOW TO: Start an iTest session interactively when the session profile uses parameters 0 Answers
How can I use variables or parameters with the json action? 1 Answer
Creating parameters using a command 2 Answers
What is the expected behavior when a parameter is redefined in the same source? 1 Answer
Copyright 2008- Spirent Communications, all rights reserved. Terms and Conditions.