# def .exec command

**URL:** <https://community.gatling.io/t/def-exec-command/1161>\
**Category:** Gatling (Open-Source)\
**Created:** [July 11, 2014, 6:29am UTC](https://community.gatling.io/t/def-exec-command/1161 "2014-07-11T06:29:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Proskurin](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@Andrei\_Proskurin](https://community.gatling.io/u/Andrei_Proskurin)\
**Post date:** [July 11, 2014, 6:29am UTC](https://community.gatling.io/t/def-exec-command/1161/1 "2014-07-11T06:29:59Z")

</div>

I am continuing to refactor the code. I wrote some basic script for get operations:

def getIt(name: String,  
link: String,  
queryKey: String,  
queryValue: String,  
pause: Int) {  
.exec(http(nimi).get(link).queryParam(queryKey,queryValue).pause(pause))  
}

But I can’t get it to work.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 11, 2014, 6:32am UTC](https://community.gatling.io/t/def-exec-command/1161/2 "2014-07-11T06:32:05Z")

</div>

def getIt(name: String,  
link: String,  
queryKey: String,  
queryValue: String,  
pause: Int) = {  
exec(http(nimi).get(link).queryParam(queryKey,queryValue).pause(pause))  
}

= so that your method actually returns something

remove leading dot: that’s for chaining

You probably should have a look at some Scala tutorial, such as [https://twitter.github.io/scala\_school/](https://twitter.github.io/scala_school/)

---

<div class="post-metadata">

**Author:** ![Andrei\_Proskurin](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@Andrei\_Proskurin](https://community.gatling.io/u/Andrei_Proskurin)\
**Post date:** [July 11, 2014, 6:51am UTC](https://community.gatling.io/t/def-exec-command/1161/3 "2014-07-11T06:51:56Z")

</div>

I upgraded it to

def getIt(nimi: String,  
link: String,  
queryKey: String,  
queryValue: String,  
pause: Int) = {  
exec(http(nimi).get(link).queryParam(queryKey,queryValue).pause(pause))  
}

But still I have: value pause is not a member of io.gatling.http.request.builder.HttpRequestBuilder

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 11, 2014, 6:59am UTC](https://community.gatling.io/t/def-exec-command/1161/4 "2014-07-11T06:59:51Z")

</div>

misplaced )

---

<div class="post-metadata">

**Author:** ![Andrei\_Proskurin](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@Andrei\_Proskurin](https://community.gatling.io/u/Andrei_Proskurin)\
**Post date:** [July 11, 2014, 7:08am UTC](https://community.gatling.io/t/def-exec-command/1161/5 "2014-07-11T07:08:16Z")

</div>

I fixed the misplaced ), but know as soon as my scenario starts it immediately crashes.  
I have  
val scn = scenario(“addNew”)  
getIt(“somePage”,“url”,“paramKey”,“paramValue”,someInt)

.exec(http(“some url”)  
…

Error message: Scenario addNew is empty

Is there anyway I can use the method getIt to make a normal working scenario?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 11, 2014, 7:52am UTC](https://community.gatling.io/t/def-exec-command/1161/6 "2014-07-11T07:52:26Z")

</div>

scenario(“addNew”)

.exec(getIt)
