好吧,我以前对JMeter和Selenium测试一直很陌生。由于后者,我想对测试进行一些模块化。但是由于某种原因,每次尝试从其他页面放置val时,都会遇到“无法解析重载的方法'exec'”的原因。现在是这样。在我看来,所有软件包都是正确的,此外,当我仅将loginPage.scala的内容复制到baseScenario中时,一切都很好。可能是因为我的主要经验是基于Java的,所以我不完全了解Scala的工作原理
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")
}