Giter Site home page Giter Site logo

Comments (8)

rangav avatar rangav commented on June 2, 2024 1

I just now tested the using the same request body and it worked for me

  • used the same script and csv file
  • script is used in collection settings pre-run scripting
Screenshot 2024-04-25 at 09 55 32

You need to increase the iterations count in run collection view
Screenshot 2024-04-25 at 10 04 13

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024

@CharlieSnowCode Thanks for the feedback. Currently, it's not possible. I will review it.

Alternatively, you can use scripting to read custom data files at the request level and set variable values.

Could you please try the scripting option and let me know your feedback?

from thunder-client-support.

CharlieSnowCode avatar CharlieSnowCode commented on June 2, 2024

I'll give it a try, could you help me get started? If each data file has 5 rows of values, how would I iterate through them? Where would the script be, in the PreRun Scripting or a custom filter file? If the file would be loaded by a custom filter, same question - how to iterate over the sets of values?

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024
  • Copy the below script to your folder settings - PreRun Scripting and modify as needed
  • change the filepath and the variable name to your defined name
var fileData = await tc.readFile("thunder-tests/test.csv");
var papaparse = require('papaparse');

var options = { delimiter: ',', quoteChar: '"', escapeChar: '"', header: true };
let csv = papaparse.parse(fileData, options).data;
console.log(csv);

var iteration = tc.info.currentIteration;

var iterationCsvData = csv[iteration];
if(iterationCsvData){
  console.log(iterationCsvData);
  var name = iterationCsvData["name"];
  console.log("name", name);

  // set variable using request scope so the value is not saved to active env file
  tc.setVar("name", name, "request");
}

sample csv file - test.csv

name,score
mike,444
john,555

from thunder-client-support.

CharlieSnowCode avatar CharlieSnowCode commented on June 2, 2024

I've attached the (Pre run) script and the .csv I'm using, a snapshot of the (Restful Booker) Request and of the output. It seems like the script sees the file, but the Request is only executed once and none of the values are populated.
preRunScript.txt
BookerDataGood.csv
Booking
Output.txt

from thunder-client-support.

CharlieSnowCode avatar CharlieSnowCode commented on June 2, 2024

Very interesting, I created a Collection and copied the script to it (I was using a folder inside an existing Collection which still doesn't work). Then increased the Iterations to 3 and it worked. Many thinks for your reply.
I would however still request the original feature be implemented, as this solution will have us creating 2 dozen Collections - which can't be executed from the UI all at once. I'm sure they can be from the CLI, but the command would be a large paragraph.

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024

For advanced use cases we recommend using scriping or cli is the best solution currently.

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024

Closing this issue as you can achieve the functionality using scripting

from thunder-client-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.