Hello!
My situatuion is quiet simple. I’ve got two menus on my site, one of them is avalaible for all users, and the other one only for admins. I have to collect all the links from the menu.
Haven’t find simple examples of using checkIf besides the Gatling documentation, so I’ve suggested to create it so as I used to in all my Java tests - to make a method with arguments.
def getMenu(menu_access: Boolean): ChainBuilder = {
exec(http("/user/${id}/first_page")
.get("/user/${id}/first_pages")
.headers(headers.headers_0)
.check(css("#block-kabinete-kab-links-1 ul a", “href”).findAll.saveAs(“links”))
.check(checkIf(menu_access)(css("#block-kabinete-kab-links-2 ul a", “href”).findAll.saveAs(“links2”))))
}
val client = scenario(“Clients”).exec(getMenu(menu_access = false))
val admin = scenario(“Admins”).exec(getMenu(menu_access = true))
But I’m getting two errors and don’t understand what is the problem even according to documentation:
checkIf(condition: Expression[Boolean])(thenCheck: Check)
inferred type arguments [io.gatling.core.check.CheckBuilder[io.gatling.http.check.HttpCheck,io.gatling.http.response.Response,jodd.lagarto.dom.NodeSelector,Seq[String]]] do not conform to method checkIf’s type parameter bounds [C <: io.gatling.core.check.Check[_]]
type mismatch;
[error] found : io.gatling.core.check.CheckBuilder[io.gatling.http.check.HttpCheck,io.gatling.http.response.Response,jodd.lagarto.dom.NodeSelector,Seq[String]]
[error] required: C
[error] .check(checkIf(menu_access)(css("#block-kabinete-kab-links-2 ul a", “href”).findAll.saveAs(“links2”))))