Search code examples
cookiesgatling

Gatling 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}"));

I tried to call addCookie method to set the cookies for the http request, as per the Gatling doc this should work https://gatling.io/docs/gatling/reference/current/http/helpers/#adding-a-cookie


Solution

  • 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: https://gatling.io/docs/gatling/reference/current/core/simulation/#dsl-imports