Open an URL from scala

Hello,
i want to edit a scala script generated from gatling to open an url.
any ideas please ?
THANK YOU

Got a code example? When you say you want to “open a url” I’m guessing that you mean you want gatling to

  1. locate a url from content retrieved by a test
  2. have gatling follow that url

If so, you might want to

  1. make sure you understand what the gatling session is
  2. look at how to extract data
  3. look at how to save data to the session (which gatling calls “session attributes”)
  4. and lastly, how to retrieve session attributes

And if you are wondering why you would need to save your data to the session and then retrieve it instead of just using it as soon as it is extracted, then you probably don’t understand the fundamental manner in which gatling works (hint: gatling is based on the Akka actor model so every execution is totally isolated from all the others and the only way data can be shared is via session attributes).

@doub1ejack thanks for the quick reply .
i’m only a beginner and learning perfomance testing so I used Gatling to test ( http://computer-database.gatling.io/ ) performance.
i added 10 computers and Everything Works just fine for me and now i want to edit the script so that after my execution is complete , http://computer-database.gatling.io will be automatically launched by gatling to make sure that the 10 computers are being added.

You know, if you need to get some load testing setup you might want to consider something other than Gatling. I just spent a few weeks building up load tests with Gatling and my ultimate opinion is that it’s probably overkill for most needs. Gatling is very low level - essentially it just gives you a library and framework for coding your own load tests. If that is what you need, then Gatling will be very flexible for you.

However, if you just need to set up initial performance test or functional tests, I’d recommend using a higher level tool until you eventually decide you need more flexibility. SoapUI is an industry standard and plenty flexible for most tests. In fact, it is the tool that other SaaS tools such as loader.io are built on top of. After a couple weeks of learning how to use gatling, I came away with tests that we will continue to use, but that could have been assembled in a fraction of the time in a GUI.

However, if you want to continue with Gatling, I’ll need a more specific question and accompanying code examples in order to help further. It isn’t clear yet what you need.

yes i would love to continue with gatling for now.

code:

package gatlingIO

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class RecordedSimulation extends Simulation {

val httpProtocol = http
	.baseURL("http://computer-database.gatling.io")
	.inferHtmlResources()
	.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
	.acceptEncodingHeader("gzip, deflate")
	.acceptLanguageHeader("fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4")
	.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36")

val headers_0 = Map("Upgrade-Insecure-Requests" -> "1")

val headers_1 = Map(
	"Origin" -> "http://computer-database.gatling.io",
	"Upgrade-Insecure-Requests" -> "1")



val scn = scenario("RecordedSimulation")
	.exec(http("request_0")
		.get("/computers/new")
		.headers(headers_0))
	.pause(30)
	.exec(http("request_1")
		.post("/computers")
		.headers(headers_1)
		.formParam("name", "azerty")
		.formParam("introduced", "2005-02-03")
		.formParam("discontinued", "2008-06-07")
		.formParam("company", "5"))

setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

}

my goal is to add a portion of code so that after i run this script , “http://computer-database.gatling.io” will be opened automatically.
i hope i made it clear for you