Q:

Modularisation of Gatling test

Okay so, I'm pretty new to this previously I've been doingonly JMeter and Selenium tests. A due to the latter I wanted to modularize my test a little bit. But for some reason everytime I'm getting a "Cannot resolve overloaded method 'exec'" when trying to put a val from a different page. Now this is how it looks. It seems to me that all packages are correct, furthermore when I simply copy the contents of loginPage.scala into baseScenario it all works just fine. It might be that I don't fully understand how Scala works as my main experience is based on Java

baseScenario.scala
   package tscgatling.base

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import tscgatling.loginPage._

class baseScenario extends Simulation{

  val urlBase = "xx"

  val httpProtocol = http
    .baseUrl(urlBase)
    .acceptHeader("image/webp,image/apng,image/*,*/*;q=0.8")
    .acceptEncodingHeader("gzip, deflate")
    .acceptLanguageHeader("pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7")
    .userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36")

  val loginNoAction = exec(loginPage.loginNoAction)

  val scn = scenario("Test")
    .exec(loginPage.loginNoAction)

  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))

}

loginPage.scala
package tscgatling.loginPage

object loginPage {

  val loginNoAction = exec(http("LoginNoAction")
  .get("/workplace/faces/portlets/pages/portletlogin.xhtml")
  .headers(loginHeaders.headers_12))
  .pause(1)
}

loginHeaders.scala
package tscgatling.loginPage

object loginHeaders {

  val headers_12 = Map(
    "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    "Proxy-Connection" -> "keep-alive",
    "Upgrade-Insecure-Requests" -> "1")

}

A:

As explained in the official documentation, you should be importing the Predefs in every file where you want to use Gatling DSL.

