Predictive search simulation - as User types in Search term, Browser sends search requests repeatedly

Hello Gatling experts,

Could you please advise how to perform following simulation.

As user types in search word, Browser Sends search request and shows possible search terms.
eg: when user tries to type housing, following search requests are sent to the server

  1. /service/search/ac?q=hou
  2. /service/search/ac?q=hous
  3. /service/search/ac?q=housi
  4. /service/search/ac?q=housin
  5. /service/search/ac?q=housing

I am trying to create simulation for this scenario.

.group(“Search from home page”){

.queryParam( “”“q”"", “${searchCriterion}.dropRight(2)”) ===> My intention is to perform search using Search term with last 2 chars truncated. This is not working. Instead search performed with “SearchCritera + dropRight(2)” string"
// .queryParam( “”“q”"", "${searchCriterion}"dropRight(2)) ====> This approach giving compile error
//.get(uri4 + “/service/search/ac?q=housi”)
.get(uri4 + “/service/search/ac”)
.queryParam( “”“q”"", “${searchCriterion}.dropRight(1)”)
// .get(uri4 + “/service/search/ac?q=housing”)
.get(uri4 + “/service/search/ac”)
.queryParam(""“q”"", “${searchCriterion}”)

.get(uri4 + “/search?q=${searchCriterion}&cat=sitesearch”) ==> This is working

  • ****<a href="([^"]+)">${searchResult}""").saveAs(“computerURL”))) // This is not working.

    Please could you also advise how to select first search result, using regular expression. search results listed for following search results

    1. Apply for housing

      Find a place to live with a council or registered social landlord.

    2. Emergency housing if you’re homeless

      Find out your options if you’re homeless and don’t have anywhere to stay tonight.

    Thanks in advance.


  • You can’t write any code you want in Gatling EL.
    You’ll have to write a function so you can use dropRight or substring: