My Problem: I have all my test data inside an excel + multiple sheets. I am trying to read the excel data & store it as a User Defined variable in Jmeter. I plan to use this:
- As a variable in a Request XML I send via SOAP/XML-RPC Request
- As a assert variable of the Response XML that I receive.
What have I done so far: I am using a similar example as in Jmeter : upload excel, hard coded values
- The first sheet has A1 and B1 cells of testfile.xlsx file as "foo" and "bar"
- I have downloaded tika-app-1.9.jar & added in the /lib folder of Jmeter(v2.13)
Added Beanshell PreProcessor & in the Script section added:
import org.apache.jmeter.protocol.http.sampler.WebServiceSampler; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.File; import java.io.FileInputStream; FileInputStream excelFile = new FileInputStream(new File("/path/to/excel/testfile.xlsx")); XSSFWorkbook workbook = new XSSFWorkbook(excelFile); XSSFSheet sheet = workbook.getSheetAt(0); XSSFRow row = sheet.getRow(0); Cell a1 = row.getCell(0); String a1Value = a1.getStringCellValue(); Cell a2 = row.getCell(1); String a2Value = a2.getStringCellValue(); excelFile.close(); sampler.addArgument("foo",a1Value); sampler.addArgument("bar",a2Value);
When I use the variable ${foo} in my SOAP/XML-RPC Request, the value does not get replaced with the value, but stays as ${foo}.
Any idea on what might be the problem here?