I am learning Gatling by watching the academy videos.
At the test website, I tried to record a select computer then delete it. (full scripts at below).
I am thinking if the ‘computer name’ is unknown/changed. How do I enhance the script to select the first record on the current page then perform delete?
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class RecordedSimulation3 extends Simulation {
private val httpProtocol = http
.baseUrl(“https://computer-database.gatling.io”)
.inferHtmlResources(AllowList(), DenyList())
.acceptHeader(“text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8”)
.acceptEncodingHeader(“gzip, deflate”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.upgradeInsecureRequestsHeader(“1”)
.userAgentHeader(“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0”)
private val headers_0 = Map(
“Sec-Fetch-Dest” → “document”,
“Sec-Fetch-Mode” → “navigate”,
“Sec-Fetch-Site” → “same-origin”,
“Sec-Fetch-User” → “?1”
)
private val headers_2 = Map(
“Origin” → “https://computer-database.gatling.io”,
“Sec-Fetch-Dest” → “document”,
“Sec-Fetch-Mode” → “navigate”,
“Sec-Fetch-Site” → “same-origin”,
“Sec-Fetch-User” → “?1”
)
private val scn = scenario(“RecordedSimulation3”)
.exec(
http(“request_0”)
.get("/computers")
.headers(headers_0)
)
.pause(3)
.exec(
http(“request_1”)
.get("/computers/501")
.headers(headers_0)
)
.pause(2)
.exec(
http(“request_2”)
.post("/computers/501/delete")
.headers(headers_2)
)
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}