question

trynitro avatar image
trynitro asked mterry answered

How do I get parameter names, not values from a parameter file?

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


iTestparametersvariable names
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

drakesh avatar image
drakesh answered Philip.Joung commented

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


forum-post.zip (2.1 KiB)
1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

trynitro avatar image trynitro commented ·

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

0 Likes 0 ·
mterry avatar image
mterry answered

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:


parameters.png (4.4 KiB)
testcase.png (11.4 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bondo avatar image
bondo answered

@trynitro You might try to use the action "dumpstate" , then store the response in a variable or create a response map for dumpstate to extract the parameters, then query for the top level names.

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.