question

WhatFurrer avatar image
WhatFurrer asked WhatFurrer posted

Adding text to URI path which is a variable in a writeFile Exec action?

All,

 

I am modifying a script on the fly in iTest exchanging the MAC address in the original script for the new one discovered on the device under test.

 

I have been able to successfully perform this feat in a test case as part of the test case sequence but did not create it as a procedure.

 

This is a function that I am wanting to convert into a QuickCall (which I have done successfully to a point ) so it can be used for other testcases.

 

The Main Issue: 

 

I can read the script file that I am wanting to modify using:

 

readFile     file:/C:/Program%20Files/VeriWave/TestScripts/$WMLscript(.wml)

 

$WMLscript is the name of the original script I am attempting to modify...It is passed in as an argument to the QuickCall without the ".wml" extension.  I have shown what I have "added" to the variable passed in as the argument shown inside the parentheses...they are not there in my test case and it accepts that as a valid URI path and reads the file as needed.

 

After making my modifications and saving it (all using TDOM inside TCL), I need to save and subsequently write the changes to a NEW file name that is based on the $WMLscript variable data passed in as the argument.  This file will be the one run as it now contains the correct MAC address for the device being tested.

 

I am attempting to use writeFile in a similar manner as I just did with readFile as shown below:

 

writeFile     file:/C:/Program%20Files/VeriWave/TestScripts/$WMLscript(_mod.wml)

 

I want to be able to add "_mod.wml" to whatever $WMLscript filename argument (NOTE: the filename is passed in without extension) is passed to the QuickCall. 

 

For Example: If I passed in the argument "DHCP_connection" as the original filename, I want the modified file to be named "DHCP_connection_mod.wml".

 

The above writeFile command line does not work as the readFile EXEC action did in regards to the URI of the file to write to.  Again, the parentheses are not included in my test case, only showing what is needed to be added to the name of the file so the URI would be different from the original filename.

 

I attempted curly braces around the "_mod.wml", but received an error.  I also tried parentheses and iTest stated that the "variable is not an array".  Square braces would be some sort of command...tried the "concat" command in square braces but that also did not work...

 

I have a number of testcases that I need to add this QuickCall to to make them more "generic" so they can be used for a number of different devices under test.

 

Ideas as to a solution?

 

Any assistance would be greatly appreciated.

 

Regards,

 

WhatFurrer


iTest
10 |950

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

1 Answer

·
JeffJ avatar image
JeffJ answered JeffJ posted

First, check that the Description is set for field substitution.  (We'll assume it is, but it's always better to check.)

 

Next, try putting curly braces around the variable name.  For example, the filename would be ${WMLscript}_mod.xml.

 

 

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.