Getting cannot find symbol [ERROR] symbol: method Cookie(java.lang.String,java.lang.String) error

Currently getting error cannot find symbol
[ERROR] symbol: method Cookie(java.lang.String,java.lang.String) for the following code. Could someone plz help

public static ChainBuilder TestABC =
        exec(addCookie(Cookie("{Key}", "{Value}").withDomain("{DomainName}").withPath("/")))
        
                .exec(http("Test API")
                .get("{URL}"));

Copy of my answer on SoF where you double posted (sad):

This piece of code is correct.

Either you’re not using a modern version that supports Gatling Java (the latest to date is 3.9.5), or your imports are a mess (missing imports, mixing conflicting imports for Gatling Java and Gatling Scala).

Please check the documentation for what your imports should look like: Gatling - Simulation

Also, please not that "{Key}" and "{Value}" are not the correct Gatling Expression Language syntax if that’s what you’re trying to use. Should be "#{Key}" and "#{Value}"

@slandelle Updating DSL imports worked like a charm. Thank you so much for your help

1 Like