CSVs and JMeter: using variables from a line in multiple samplers



  • I'm trying to create a test with JMeter to log in many users and test a website. Each user has a username, a password, and a special id number. The associated id number needs to go into the URL for some requests from that user.

    I had thought that I could create a CSV file to read these variables, like this:

    username,password,id
    username2,password2,id2
    username3,password3,id3
    

    However, that doesn't seem to work. I put the CSV Data Set Config element directly under the Test Plan because I want each line to be a thread (each thread representing a separate user who is making several requests). I also tried moving it to be a child of the Thread Group. The username and password seem to be working alright (they are in the first request, to log in), but I am getting in requests where I reference the id. Where have I gone wrong?

    I am currently only trying this with one user to get it working. There are no extra line feed characters, the csv file consists only of a single line, two commas, letters and numbers, no spaces. I'd already checked that because I found someone with an problem who said they'd been getting it for that reason.



  • In regards to placement, you need to provide enough iterations to CSV Data Set Config so it could go for 2nd and further lines. So it makes sense to put CSV Data Set Config as a child of a Thread Group or Loop Controller.

    Regarding id bit. Any change that username and/or password contains comma? If so, you may have to check "Allow quoted data" to work it around.

    See Using CSV DATA SET CONFIG guide for more details. If anything is unclear update your question with CSV file content (can be partial) and your CSV Data Set Config details.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2