Help

Hi All,

Please I need help to correctly complete my script design. I am still relatively new to Gatling.

There are 2 areas I need help with.

  1. To be able to extract a dynamic value (366) from the body of a page and use it as part of url in subsequent pages.

  2. To be able to parameterize the 2 scenarios - checking Yes button, and selecting any country (address) from the list on that same page.

Scenario explanation:

The mockup web page is https://aaaa.com/bookings/366/overview/.
This page is generated as a result of ongoing application. As you can see from the attached photos (web result and corresponding inspect snapshot) that once the booking code (OC000001) is chosen from the previous page (not included), an auto-increment value (366) is attached. This value then becomes part of the next 2 user scenarios. See photos link 1 url and link 2 url.

These 2 links (scenarios) on the mockup page completes the booking process. When the first link (https://aaaa.com/bookings/366/validid) is clicked, it ask you “Do you have a valid ID?”. If you pick yes from the radio button, it takes you to the next page (https://aaaa.com/bookings/366/address) where you will enter your country (address) to complete the application.

Extract of my script is shown below. Please note that I reverted to the original script (but with little amendment when I was getting too much errors.

package Bookings

  import scala.concurrent.duration._
  import scala.util.Random
  import io.gatling.core.Predef._
  import io.gatling.http.Predef._
  import io.gatling.jdbc.Predef._

  class aaaaa extends Simulation {

    val httpProtocol = http
      .baseURL("[https://aaaa.com/](https://aaaa.com/)")
      .inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", 
        """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
      .acceptEncodingHeader("gzip, deflate")
      .userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36")

    object Apply_Booking {
      val apply_booking = exec(http("Booking Page")
        .get("/bookings")
        .headers(headers_1))
        .pause(2)

    }

    object Select_Booking {
      // Booking Application

      val select_Booking = exec(http("Booking")
        .get("/bookings/366/overview")
        .headers(headers_1)
        .formParam("Fields[Booking]", "309") //database id for the chosen booking code
        .formParam("Fields[SubmitButton]", "Save and continue")
        .formParam("security", "826e515ff016e7f9b1597506659eb9"))
        .pause(25)

    }

    object ValidId{
      val validid = exec(http("Valid ID")
        .get("/bookings/366/validid/")
        .headers(headers_1))
        .pause(2)

        // Confirm Valid ID
        .exec(http("Confirm Valid ID")
        .post("/bookings/366/validid")
        .headers(headers_1)
        .formParam("Fields[ValidId]", "No")
        .formParam("Fields[ValidId]", "Yes")
        .formParam("Submit[SubmitButton]", "Save and continue")
        .formParam("security", "774e0f4a7e994a185b622748a72"))
        .pause(4)
    }

    object Country{
      val country = exec(http("Goods to Austria, Hungary, etc")
        .post("/bookings/366/address")
        .headers(headers_1)
        .formParam("Fields[restrictedCountries]", "1")
        .formParam("Fields[countriList][countryList][]", "AT|Austria")
        .formParam("Fields[countriList][countryList][]", "US|United States")
        .formParam("Submit[SubmitButton]", "Save and continue")
        .formParam("security", "bea7c9546531d576ef24f4afa8d"))
        .pause(5)
    }

    object Finish {
      val finish = exec(http("Finish")
        .get("/Bookings")
        .headers(headers_1))
        .pause(3)
    }

    val headers_1 = Map("Accept" -> "*/*")

    val newapplication = scenario("NewApplication").exec(Apply_Booking.apply_booking, Select_Booking.select_Booking, 
      ValidId.validid, Country.country,Finish.finish)

      setUp(newapplication.inject(nothingFor(3),
        atOnceUsers(13),nothingFor(3),
        rampUsers(7) over 2))
        .protocols(httpProtocol)

  }

webpage view.PNG

link 1 url.PNG

link 2 url.PNG

I think your problem is not so difficult. Read the examples in gatling-charts-highcharts-bundle-2.3.1\user-files\simulations\computerdatabase , you are going to find some answers.