Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jmeter Upload Error in Recording

I am trying to record a session in which there is a upload functionality.
I have used http proxy server for recording, recording controller and http cookie manager.
When I try to upload a file and click save it shows following error:

java.io.FileNotFoundException: a12-13538_110q.htm (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(Unknown Source) at java.io.FileInputStream.(Unknown Source) at org.apache.jmeter.protocol.http.sampler.PostWriter.writeFileToStream(PostWriter.java:408) at org.apache.jmeter.protocol.http.sampler.PostWriter.sendPostData(PostWriter.java:117) at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sendPostData(HTTPJavaImpl.java:115) at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:510) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1060) at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:238)

This functionality works fine when I am not using jmeter recording.

Kindly help on this.
Is there any way I can perform this test?

like image 314
Divesh Salian Avatar asked Sep 11 '12 09:09

Divesh Salian


People also ask

Can we upload file in JMeter?

JMeter's HTTP Request Sampler in its turn offers a “Use multipart/form-data for POST” checkbox. Ticking this checkbox indicates that the request contains file data. The file(s) needs to be supplied through “Files Upload”' input.

How to import file in JMeter?

In the Test Navigator, right-click and click Import. In the Import dialog box, expand General in the source list, select File System and then click Next. Specify the directory where the JMeter test resides. Click Browse to select a directory from where you can import the JMeter test.

How to give file path in JMeter?

The solution is to copy the file to the bin directory of JMeter. This way JMeter will pick up the file using the relative path and you'll have a successful recording. Or you can give the absolute path in the HTTP sampler so that JMeter picks the file from the location specified from the HTTP sampler.


1 Answers

Bug 50079: Jmeter does not record the file path.

As per your exception jmeter cannot find file to upload, because of issue mentioned above.
So you have to set path manually in sampler, and it's better to use variable for this, for test parametrization.

Don't use record-and-playback at all, or at least check and adjust your recorded samplers.
In your case you have to set in recorded http [POST] request following:

  • Use multipart/form-data for POST = true - to sent file as part of request;
  • Send Files with Request -> File Path = PATH_TO_FILE - path to existent file, directly or using variable.
    . . .
    UPLOAD HTTP Request
    Method = POST
    Use multipart/form-data for POST = true
    -- Send Files with Request -- section:
    File Path = ${testFile}
    Parameter Name = datafile
    MIME Type = ...
    . . .
like image 74
Aliaksandr Belik Avatar answered Sep 25 '22 19:09

Aliaksandr Belik