Ask a Question

Test step to import file, partial file name is known


Test step to import file, partial file name is known

Hey all, I'm a beginner at this so bear with me ...


I am trying to import a file from a specific Windows folder that is created with a unique file name by my API that includes a reference number that I sent.


A request is sent POST to the REST API with 16 digit reference number that I generate randomly for the request. The API I am testing responds to the POST with an Initial Response and creating a file using the reference number along with specific text, and at the end a date/time stamp (to maintain a unique file name) so the file looks something like this ...


After nearly a minute, the API creates another file intended as the final response with data the API requested from the service.  The file name used contains the same text and the reference number except the time stamp is new AND is located in a "FinalResp" folder.  looks like this ...



I researched several different ways to select this specific file to use its contents for validation, but the problem is I dont know what the actual file name is ...

I tried in Groovy to copy the response_1234567890123456 using the "*" wildcard to a different folder, unsuccessful ... I dont think Groovy has a method to copy files using wildcards.

I tried to use a wildcard in a property and transfered the property into a file wait test step, but the step failed as it doesnt like the wildcard.


I know the text and reference number, but I dont know what the stamp will be...

I am thinking that if I could use Groovy script to create an Array from the contents of the "FinalResp" folder, I can search the array using "Contains" for the reference number, then I will have the full file name to import the contents of the XML for validation.


I do NOT have any idea how to do this in Groovy.  Ideas?  someone have a useful snippet?


Please? and thanks

Showing results for 
Search instead for 
Did you mean: