scala - How do I reference a variable from a CSV Feeder in Gatling?

I'm trying to feed URLs into a Gatling simulation from a CSV file and I'm getting the following error:

11:48:01.967 [ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-1' failed to execute: No attribute named 'Url' is defined

My data file looks like this:

Url
/foo
/bar

And my simulation is as follows:

val httpProtocol = http
    .baseURL("https://example.com")

val csvFeeder = csv("urls.csv").random

val scn = scenario("Simulation")
          .feed(csvFeeder)
          .exec(http("request_0")
            .get("${Url}")
          )

setUp(scn.inject(
    atOnceUsers(1),
    rampUsers(3) over(5 seconds),
    constantUsersPerSec(3) during(600 seconds) randomized
)).protocols(httpProtocol)

If I debug the simulation (I'm using IntelliJ FYI) I can see csvFeeder has 2 records, each record is a Tuple2 and if I dig in to that I can see that _1 = "Url" and _2 = "/foo" so the feeder is loading the data.

Why am I getting the error No attribute named 'Url' is defined ?

I'm using Gatling version 2.1.7.

2 Answers

  1. Loren- Reply

    2019-11-13

    It turns out the issue was due to the input CSV file having a UTF-8 BOM. Removing the BOM fixed the issue.

  2. Lori- Reply

    2019-11-13

    You're doing it the right way.

    Possible explanations:

    • You're not loading the same file when running Gatling and when debugging from IntelliJ
    • You actually have a typo in your column header

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>