dynamic form

60 views
Skip to first unread message

Nathanael Noblet

unread,
Apr 26, 2016, 6:39:23 PM4/26/16
to Gatling User Group
Hello, I've recently found gatling.io. Its pretty awesome. I've got one issue. I'm trying to build a test scenario to load test one part of a system. A user logs in, and then selects one 9 radio buttons. As the system continues one of each of those may no longer be available. So I'm wondering how I go about submitting a form based on the options that are available? I presume I would use some regex/check but I can't seem to find anything doing anything like this. Here's my simulation as it stands now. the last line where I set slot_booking[block] to 12. 


package carms

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class BasicSimulation extends Simulation {

  val users = csv("users.csv").random

  val httpConf = http
    .baseURL("http://carms") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .doNotTrackHeader("1")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val headers_10 = Map("Content-Type" -> "application/x-www-form-urlencoded") // Note the headers specific to a given request

  val scn = scenario("Login and book") // A scenario is a chain of requests and pauses
    .exec(  http("getlogin").get("/login")  )
    .pause(3)
.feed(users)
.exec(
http("postlogin")
.post("/login_check")
.headers(headers_10)
.formParam("_username","${email}")
.formParam("_password","${password}")
.check(regex("""<h1>Interview Booking</h1>"""))
)
    .exec(  http("get interview times").get("/booking/interview-times")  )
    .pause(1)
    .exec(
            http("post interview times") // Here's an example of a POST request
     .post("/booking/interview-times")
     .headers(headers_10)
     .formParam("slot_booking[attendingCarmSocial]", 0) // Note the triple double quotes: used in Scala for protecting a whole chain of characters (no need for backslash)
       .formParam("slot_booking[block]", 12)
)

  setUp(scn.inject(atOnceUsers(9)).protocols(httpConf))
}

Stéphane LANDELLE

unread,
Apr 29, 2016, 4:57:26 AM4/29/16
to gat...@googlegroups.com
You'll have to implement this logic on your side.
Note that the new "form" component could help: http://gatling.io/docs/2.2.0/whats_new/2.2.html#forms-support

Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages