Forum Discussion

canpan14's avatar
canpan14
Occasional Contributor
9 years ago

Cannot Change Output File Within a Loop

I'm trying to loop over several excel files in a directory, perform some actions, then output a new file for each one of those based on what I did.

 

My script is performing all of the actions correctly except it will not rename the out file in the Data Sink step. It will just keep using the same file and dump everything into it.

 

I've tried several ways of changing the output file name with no luck (Use property transfer, direct reference, groovy script).

I have confirmed through debugging that it is correct grabbing the next file name and performing the actions on all the files. It just wont change the Out File name.

 

Any help or suggestions on things to try would be great.

 

Thanks!

  • nmrao's avatar
    nmrao
    Champion Level 3
    A screen shot showing the problem and your script will help to get the faster resolution.
    • canpan14's avatar
      canpan14
      Occasional Contributor

      I'm not sure how to properly screenshot it but I will try.

       

      Here is the first screenshot with the test flow. It is pretty simple.

       

      In the below screenshot. It runs over several files (On the left). But always just outputs to a single file on the right (All of the data is correct in the file, but it needs to be split up into multiple).

       

      The code to change the output path is pretty simple and I've already tested it works correctly.

      def filename = context.expand( '${Read in File Names#Filename}' )
      def outPath = "PATH/" + filename + ".xlsx"
      testRunner.testCase.testSteps['Properties'].setPropertyValue("OutputPath",outPath)

      Also here is the datasink step.

       

       Thanks

      • canpan14's avatar
        canpan14
        Occasional Contributor

        Quick update. I tried slimming down the test to just loop and make multiple output files (Changing the output name), ignoring any data changes.

         

        Still ran into the same issue. So maybe this just isn't possible. At least with excel files.

         

        Might stem from the fact that soapui doesn't like release files from memory sometimes.