vins
vins

Reputation: 37

How to upload file in Front End using Jmeter?

I am trying to upload a file using jmeter on the front end. There are three files that are need to be uploaded and then the Submit button will be enabled. Is there any way to it through jmeter?

I am able to do it from the back end. But i want to use the URL of the website through Jmeter in order to do performance testing of the website.

Upvotes: 1

Views: 24285

Answers (2)

Gurpreet Kaur
Gurpreet Kaur

Reputation: 31

Steps to perform:

  1. Add HTTP Request in TestPlan
  2. Select the post/put method
  3. Type in the PATH
  4. Select use multipart/form-data
  5. Under the File Upload tab, enter the file path, Parameter Name, and MimeType.
    MIME Type examples: image/jpeg, image/png, text/plain
  6. Save and run the test.

Screenshot below:

enter image description here

Upvotes: 3

Dmitri T
Dmitri T

Reputation: 168157

As per very main page of the Apache JMeter project:

JMeter is not a browser.

As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).

So JMeter won't check the status of the "Submit" button, it acts on protocol level and will send the corresponding request in any case.

In regards to the File Upload bit itself. You can do it with HTTP Request sampler, just make sure:

  1. You use POST (in some cases it can be PUT) method

  2. Use multipart/form-data for POST box is checked

  3. In Files Upload section the following values are provided:

    • File Path (either absolute or relative to JMeter's "bin" folder)
    • Parameter Name (form name which contains <input type="file" ... tag, you can figure that out from upload page source code)
    • File MIME Type

Actually the easiest way to build a file upload request is just recording it, see Recording File Uploads with JMeter guide for more details.

Upvotes: 4

Related Questions