How to ensure a pdf is downloaded during a loadtest?

Hi,

I have a script where two requests are triggered when I mimic click on a download button. Manually if I do it in UI it works fine and the file is downloaded into my local. However, if
I try the same via script gatling shows everything works fine but the file is not present in my local.

The two requests are as follows:

exec(
http(“S3.1 - get.php download simple”)
.post("/participant/controller/flow/get.php")
.formParam(“action”, “111”)
.formParam(“fileId”, “${simpleFileId}”)
.formParam(“containerId”,"${simpleContainerId}")
.formParam(“flowId”, “${testId}”)
.formParam(“csrfId”, “${csrfId}”)
.check(
status.is(200)))

.exec(
http(“S3.2 - newset.php action 308 simple”)
.post("/participant/controller/flow/newset.php")
.formParam(“flowId”, “${testId}”)
.formParam(“action”, “308”)
.formParam(“value[userid]”,"${testInf.userId}")
.formParam(“csrfId”, “${csrfId}”)
.check(
status.is(200)
))

I did some reading related to other performance tools and it suggests setting response headers content-disposition: attachment or content-type: pdf/application. However, in the application Is there a way by which I can save the response header and change it so that the file will get downloaded? For the new header do I need to send a fresh request?
Thanks in advance

Hi Reetu,

How did you achieve this? I have a same scenario. If someone can post solution that would be more helpfull.

Thanks.

Hi,
I am trying to achieve similar scenario with my application.
Did you find the solution for this.

Thanks,
Prad

Hi all!

You can try bodyBytes or bodyStream in the check section.

Cheers!

Below you have Example in Java:

import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;

public class PDFdownloadSimulation extends Simulation {

   // https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
    HttpProtocolBuilder httpProtocol =
            http
                    .baseUrl("https://www.w3.org");

    ScenarioBuilder scn =
            scenario("Scenario Name")
                    .exec(
                            http("request_1")
                                    .get("/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")
                                    .check(bodyBytes().is(RawFileBody("dummy.pdf")))
                                    .check(bodyLength().is(13264))
                    );

    {
        setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol));
    }
}

Hi all,
I send a (.json) request from gatling script which in response downloads the file.

I have logback.xml settings to capture this response in a log file. Here, I could see the file contents are derived as part of the session value in a List in a Log file. This confirms the file is downloaded with each user request.

My query is, how could we get the physical file on the disk or in downloads folders with each iteration.

Appreciate your support.

Thanks,
Prad

Since you receive your content, you can write it on file.

I’m curious, why do you need your files on disk? As Gatling is a load testing tool, at high usage your disk will be empty (and performance of writing on disk is very poor)

Sure, Thanks for the update.

Basically, I had run similar scenario in JMeter, there we used plugin “Save Responses to a file” which was able to download .pdf file and save to bin folder. So I was thinking if we have something similar in Gatling.

Thanks,
Prad