Forum Discussion

Sobana's avatar
Sobana
Occasional Contributor
7 years ago

Is there any way to fetch my xml file from my local in a sequential manner

I am fetching my xml requests from my local using groovy script and getting responses.

And i am using property transfer to JDBC request for validation.

 

But the requests are not fetched in the sequential manner. I want to fetch my xml file based on the name.

 

example:

req1.xml

req2.xml

req3.xml

 

If i am having these 3 xmls in my local, then i need my script to fetch req1.xml first, then req2.xml and so on...

 

Is there any way to do this?

1 Reply

  • avidCoder's avatar
    avidCoder
    Super Contributor

    You can handle this using File in java. Go through this code:-

     

    //Use File Counter to increase file count and set it at testCase level:-
    
    fileCtr = Integer.parseInt(fileCtr) + 1
    testRunner.testCase.setPropertyValue("fileCtr",String.valueOf(fileCtr))
    
    //It will read the file in String
    
    File resFolder = new File(path_of_folder_where_files_resides)
    File[] listOfFiles = resFolder.listFiles();
    File fOut = listOfFiles[Integer.parseInt(fileCtr)];
    String res = FileUtils.readFileToString(fOut)
    log.info res
    
    
    

    Hope, it helps you out.