0

I have enroll students via bulk upload process through xls document in my application. Can you explain step by step process for upload student details through xls document in Jmeter3.0.

Thanks, Vairamuthu.

Vairamuthu
  • 528
  • 4
  • 11
  • 20

1 Answers1

0

As far as I know JMeter doesn't supply a sampler to upload from xls directly.

So I suggest to convert the input file in CSV and use the Config element "CSV Data Set Config". You can find a lot of step-by-step examples on internet.

Anyway, you can read xls file using Apache Tika and BeanShell (sampler, pre or post processor depending on your needs and test plan).

Here an example using HTTP request sampler to read the xls file (or more generic a binary file):

  • Download tika-app.jar (JMeter 3.0 uses version 1.12 tika-app-1.12.jar )
  • Copy tika-app.jar file to jmeter/lib directory.

  • Restart JMeter

  • Open a JMeter test plan and add Thread group

  • Add an "HTTP request" sampler.

    • Set the field "Protocol[http]" to "file".

    • Set "Path" field to your file pathname (e.g. /mypath/Students.xlsx ) enter image description here

  • Nested to "HTTP Request" add a "BeanShell PostProcessor"

    • In the "Script" area add the following code (assuming in this example that your xls file has a sheet "Sheet1", three columns, the first row as header); it reads the file and sets A1, B1, C1 jmeter variables:
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

try {

   InputStream in = new ByteArrayInputStream(data);
   Workbook wb = new XSSFWorkbook(in);
   in.close();
   Sheet sheet1 = wb.getSheet("Sheet1");
   Row row = sheet1.getRow(1);
   Cell a1 = row.getCell(0);
   Cell b1 = row.getCell(1);
   Cell c1 = row.getCell(2);
   vars.put("A1", a1.getStringCellValue());
   vars.put("B1", b1.getStringCellValue());
   vars.put("C1", c1.getStringCellValue());
}

catch (Throwable ex) {
   log.error("Failed ", ex);
}

enter image description here

  • Below "HTTP Request" Sampler, at the same level, add a "Debug" Sampler and a "View Result Tree" to see the variables (A1, B1, C1)

enter image description here

This is just an example about xls reading in JMeter, then you can decide to start from here to get something useful.

See also these articles from BlazeMeter or tech-doing.com

gile
  • 5,580
  • 1
  • 25
  • 31