Passing random credentials into proxy credentials - compilation error (missing parameter type)

Hi,

I have the need to provide a range of proxy usernames and passwords, randomly picking from a list. I already have the http conf being set up with a random UA each time it’s used, as shown below (randomUA), but I’m struggling to achieve the same thing with the credentials (I think because it’s expecting String inputs rather than Expression[String])

//The UAs.scala file contains a userAgents Array of UA Strings - this just
//picks randomly from that array.

def randomUA: Expression[String] = {
s => UAs.userAgents.get(util.Random.nextInt(UAs.userAgents.length))
}

//The Users.scala file includes an array of arrays, each of which contains a
//pair of Strings - the username and password. Want this to pick randomly from that set.
def randomUserPword: Array[String] = {
s => Users.userpwords.get(util.Random.nextInt(Users.userpwords.length))
}

val httpConf = http
.userAgentHeader(randomUA)
.proxy(Proxy(“proxy.somewhere.com”, 8080).httpsPort(443).credentials(randomUserPword(0),randomUserPword(1))

I’m then using this httpConf when doing the injection. The UA is working fine (I can see it changing each time when the proxy is commented out).

On compiling, I’m getting the error:

10:38:15.150 [ERROR] i.g.c.ZincCompiler$ - /Users/robertgates55/gatlingDemo/demo1/user-files/simulations/ai/BaseTest.scala:32: missing parameter type

10:38:15.154 [ERROR] i.g.c.ZincCompiler$ - s => Users.userPwords.get(util.Random.nextInt(Users.userPwords.length))

10:38:15.154 [ERROR] i.g.c.ZincCompiler$ - ^

10:38:15.324 [ERROR] i.g.c.ZincCompiler$ - one error found

What am I doing wrong?

Thanks,

Rob