# Using a session variable as pause time

**URL:** <https://community.gatling.io/t/using-a-session-variable-as-pause-time/712>\
**Category:** Gatling (Open-Source)\
**Created:** [December 10, 2013, 1:51am UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712 "2013-12-10T01:51:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Pulver](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Alejandro\_Pulver](https://community.gatling.io/u/Alejandro_Pulver)\
**Post date:** [December 10, 2013, 1:51am UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/1 "2013-12-10T01:51:36Z")

</div>

Hello,

I have some code that looks like this:

[…]

.exec(http(“Go to Sign Up”)  
.get("""/users/sign\_up""")  
.headers(headers\_1))  
.pause(28)

String session variables can be used with the “${var}” syntax, but I would like to use a numeric session variable (from a feeder) as the amount of seconds to pause. Is that possible?

Thanks,  
Alejandro

---

<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:** [December 10, 2013, 8:28am UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/2 "2013-12-10T08:28:32Z")

</div>

Hi,

Only in Gatling 2:  
pause("${var}", java.util.concurrent.TimeUnit) if var is an Int  
pause("${var}") if var is a Duration

---

<div class="post-metadata">

**Author:** ![Alejandro\_Pulver](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Alejandro\_Pulver](https://community.gatling.io/u/Alejandro_Pulver)\
**Post date:** [December 10, 2013, 2:59pm UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/3 "2013-12-10T14:59:30Z")

</div>

Thanks. I’ve tried with your first suggestion, but it fails with the following error:

11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - /home/ale/Downloads/mercury\_lms/gatling\_oficina/user-files/simulations/LawVaultSimulationv2  
.scala:65: object java.util.concurrent.TimeUnit is not a value  
11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - .pause("${delay\_one}", java.util.concurrent.TimeUnit)  
11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - ^

I’m using 2.0.0-M3.

By the way, I had no success using gatling from Eclipse. Is there an updated guide?

---

<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:** [December 10, 2013, 3:03pm UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/4 "2013-12-10T15:03:46Z")

</div>

java.util.concurrent.TimeUnit is a java enum =\> [http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html)  
SECONDS, MILLISECONDS…

---

<div class="post-metadata">

**Author:** ![Alejandro\_Pulver](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Alejandro\_Pulver](https://community.gatling.io/u/Alejandro_Pulver)\
**Post date:** [December 10, 2013, 3:12pm UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/5 "2013-12-10T15:12:45Z")

</div>

Ah. It outputs the following with SECONDS.

12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - /home/ale/Downloads/mercury\_lms/gatling\_oficina/user-files/simulations/LawVaultSimulationv2  
.scala:66: overloaded method value pause with alternatives:  
(minDuration: scala.concurrent.duration.Duration,maxDuration: Option[scala.concurrent.duration.Duration])io.gatling.core.structure.C  
hainBuilder   
(minDuration: scala.concurrent.duration.Duration,maxDuration: scala.concurrent.duration.Duration)io.gatling.core.structure.ChainBuil  
der   
(minDurationExp: io.gatling.core.session.Session =\> io.gatling.core.validation.Validation[scala.concurrent.duration.Duration],maxDur  
ationExp: io.gatling.core.session.Session =\> io.gatling.core.validation.Validation[scala.concurrent.duration.Duration])io.gatling.core  
.structure.ChainBuilder  
cannot be applied to (String, java.util.concurrent.TimeUnit)  
12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - .pause("${delay\_one}", SECONDS)  
12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - ^

---

<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:** [December 10, 2013, 3:20pm UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/6 "2013-12-10T15:20:12Z")

</div>

Sad news, this methods only exists in master (next version).  
If you don’t want to walk on the wild wild side and upgrade to master, you’ll have to first build a duration:

.exec{ session =\>  
for {  
delayOne ← session(“delay\_one”).validate[Int])  
} yield session.set(“delay\_one\_duration”, delayOne seconds)  
}

.pause("${delay\_one\_duration}")

---

<div class="post-metadata">

**Author:** ![Alejandro\_Pulver](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Alejandro\_Pulver](https://community.gatling.io/u/Alejandro_Pulver)\
**Post date:** [December 10, 2013, 8:57pm UTC](https://community.gatling.io/t/using-a-session-variable-as-pause-time/712/7 "2013-12-10T20:57:43Z")

</div>

OK. Thank you for your answers.
