Different protocol within same scenario and access currently selected domain

Hi I have two questions:

  1. I have a scenario for which need to alter between different protocols: http and https. It looks like below:

scenarioWithPostalCode(“ATL Scenario”)

.exec(http("/summary") <===== Using http

.get(“http://domain.com/summary”))

.pause(1)

.exec(http("/sign-in") <===== Using https

.get(“https://sign-in”))

.pause(1)

Currently I am having to insert the protocol with domain and not use scenario.inject(…).protocols(httpConf). Is there a better way to support both http and https within the same domain?

  1. Second of all, for one kind of service, I am alternating between few urls using http.baseURLs(…,…,…) method. At run time, randomly a url is selected. Is there a way to access currently selected domain? HttpProtocolBuilder doesn’t seem to have any sufficient method.

Thanks

Use Scala String interpolation.

val domain = “domain.com

scenarioWithPostalCode(“ATL Scenario”)

.exec(http(s"http://$domain/summary").get("http://domain.com/summary"))

.pause(1)

.exec(http(“https://$domain/sign-in").get("https://sign-in”))

.pause(1)

More tricky.

You could write a function, such as:

def url(scheme: String, path: String): Expression[String] =

(session: Session) => {

val domain = ThreadLocalRandom.current.nextInt(3) match {

case 0 => “domain0”

case 1 => “domain1”

case 2 => “domain2”

}

s"$scheme://$domain/$path".success

}