<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">

How to read special characters from CSV in JMeter?

Kishore Bhamare Nov 26, 2018

JMeter

In performance testing, you may come across a scenario where you want to read data from CSV file and post that data in HTTP request which contains any of the following special characters:

  • Ceña
  • Dr. Bosé
  • St. Edward's University
  • Robert Hermès of Paris Inc.,
  • Noticiero Univisión
This can be achieved in 5 simple steps. Let’s have a look at it in detail:

  • Launch Apache JMeter (Version 5.0)
  • Add ‘CSV Data Set Config’ from ‘Config Element’
    • Filename: Provide Filename (It is good to provide full path even if your file is in bin folder)
    • File encoding: Different file encoding options are available. Select appropriate to suit your need [UTF-8, UTF-16, ISO-8859-15, US-ASCII]. It indicates your input file encoding. Nowadays CSV file comes with the UTF-8 format by default
    • Variable: Give variable name, separated by a comma
    • Ignore the first line: If your CSV file’s first row contains heading of column (variable name) then use this option as ‘True’ otherwise set it to ‘False’
    • Delimiter: If you are using more than one variable in your CSV file then use this option. By default, it takes comma as a delimiter. You can also use the pipe as a separator
    • Allow quoted data?: If CSV contains data within double or single quote then set this option as ‘True’ otherwise ‘false’
    • Recycle on EOF: If want to re-use CSV data after reaching EOF then set to ‘True’
    • Stop thread on EOF?: This is to determine that when one reaches EOF whether the thread should stop. The default is ‘False’.
    • Sharing mode:
      • All threads - (the default) the file is shared among all the threads
      • Current thread group - each file is opened at once for each thread group in which the element appears
      • Current thread - each file is opened separately for each thread
      • Identifier - all threads sharing the same identifier share the same file. For example, if you have 4 thread groups, you could use a common ‘ID’ for two or more of the groups to share the file between them or you could use the thread number to share the file between the same thread numbers in different thread groups.
csv-data-set-config
  • Add HTTP Request (Sampler)
    • Add your parameters
http-request
  • Add ‘Debug Sampler’. It is required just to make sure that the CSV reads values (special characters) correctly
  • Run the script and verify. If it does not show special character (Shows something like “Pe?a”) in the application UI then, add Content encoding as UTF-8.

http-request-verify
Now this time it should definitely work.

Note: If URL contains special characters then you can use JMeter predefined function (${__urldecode(${firstName})} Goto JMeter-->Options-->Function Helper Dialog)

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.