5
votes

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?

2
Please also refer to answer mentioned here: stackoverflow.com/questions/14121551/… - you can just put uploaded files in Jmeter's bin directory, then Jmeter will find them without problemsYuriy Nakonechnyy

2 Answers

6
votes

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 = ...
    . . .
0
votes

This is related to the defect mentioned above. But the workaround is (On windows) to place the file that is being uploaded in the same folder as the JMX file is. (The file path is not captured only the file name is captured here. Hence need to update the correct absolute or relative path accordingly once the requests are captured.)