Reply
Member
tsimal
Posts: 4
Registered: 03-24-2010
0

Read lines from a txt file (variable number of lines)

Hi everybody

 

I am helping a customer to evaluate iTest, and they asked me a question, and really.. I don't know how to solve it.. :-(

 

the would like to have a list of parameters in a txt file, so the script can read the lines and execute the tests several times, each one with different values.

 

So I need to access to a textfile, read a line, use the parameters to run the tests, read second line, use it to run again the test with new values... and so on, but the numbers of lines are not fixed, so I cannot assign variables in static way...and that is the only way I found through readFile command..

 

Anyone could help me?

 

Thanks!!!

 

 

Fanfare
GuanghongY
Posts: 109
Registered: 09-04-2008
0

Re: Read lines from a txt file (variable number of lines)

You can use readFile read the whole file's content and store it to a variable (say "my_params"), then in the analysis rule of the action use [query $my_params line()] to get content of each line. You will need to create a corresponding response map for the readFile action. You can then wrap this with a "foreach" loop to run procedures on each of the parameters. Please refer to these posts for more details:

 

http://forums.fanfaresoftware.com/t5/General-iTest-Topics/Reading-a-file-storing-it-s-content-in-a-t...


http://forums.fanfaresoftware.com/t5/General-iTest-Topics/Can-iTest-read-a-text-file/m-p/170/highlig...

Member
tsimal
Posts: 4
Registered: 03-24-2010
0

Re: Read lines from a txt file (variable number of lines)

Thanks a lot!!! it is clear now :-)

Community Leader
PaulD
Posts: 1,214
Registered: 09-02-2008
0

Re: Read lines from a txt file (variable number of lines)

Note that if you are willing to use a simple XML file format rather than a text file format, then it is even easier, because when you call readFile on that XML file, it will already be structured with queries to fetch all of the information you want from it.  Either way works, though.